Skip to content
Snippets Groups Projects

Feat git commit agent

Merged Bo-Chun Chen requested to merge github/fork/diedpigs/feat-git-commit-agent into feat-cod-rmq

In this code, I assume that the ticketnum is passed. We might need to adjust the producer for this.

Included --dry-run and --verbose option that user can pass in when starts the agent. Include logging module for better way to control logging level.

Merge request reports

Merged by avatar (Jul 10, 2025 6:46pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Created by: rtripath89

    Review: Approved

  • Ravi Tripathi
  • Ravi Tripathi
  • Ravi Tripathi
    Ravi Tripathi @ravi89 started a thread on commit d75c72d8
  • 1 #!/usr/bin/env python
    2 import os
    3 import sh
    4 import sys
    5 import json
  • Ravi Tripathi
    Ravi Tripathi @ravi89 started a thread on commit d75c72d8
  • 11 # Instantiate rabbitmq object
    12 rc_rmq = RCRMQ({'exchange': 'RegUsr', 'exchange_type': 'topic'})
    13
    14 # Define some location
    15 repo_location = os.path.expanduser('~/git/rc-users')
    16 users_dir = repo_location + '/users'
    17 groups_dir = repo_location + '/groups'
    18
    19 args = rc_util.get_args()
    20 logger = rc_util.get_logger(args)
    21
    22 if not args.dry_run:
    23 git = sh.git.bake('-C', repo_location)
    24 ldapsearch = sh.Command('ldapsearch')
    25 else:
    26 git = sh.echo.bake('git', '-C', repo_location)
    • Created by: eesaanatluri

      This works in git versions > 2.4 but we have git version 1.8 by default so for backward compatibility we can change the line 26 to this git = sh.git.bake('--git-dir', repo_location+'/.git', '--work-tree', repo_location)

  • Ravi Tripathi
    Ravi Tripathi @ravi89 started a thread on commit d75c72d8
  • 40 logger.debug("ticketnum: %s", ticketnum)
    41 logger.debug("branch_name: %s", branch_name)
    42
    43 try:
    44
    45 logger.debug('git checkout master')
    46 git.checkout('master')
    47 logger.debug('git pull')
    48 git.pull()
    49 logger.debug('git checkout -b %s', branch_name)
    50 git.checkout('-b', branch_name)
    51
    52 logger.debug("open(%s, 'w'), open(%s, 'w')", user_ldif, group_ldif)
    53 with open(user_ldif, 'w') as ldif_u,\
    54 open(group_ldif, 'w') as ldif_g:
    55 logger.debug(f"ldapsearch -LLL -x -h ldapserver -b 'dc=cm,dc=cluster' uid={username} > {user_ldif}")
    • Created by: eesaanatluri

      In lines 55-58 the -h ldapserver may have to be changed to -H ldaps://ldapserver to work right out of the box in our current setup of CoD. This might need a review in the meeting if this approach would be ok.

  • Merged by: rtripath89 at 2020-09-25 20:05:11 UTC

  • Please register or sign in to reply
    Loading