Feat git commit agent
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
Activity
Filter activity
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) 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}")
Please register or sign in to reply