def create_bug(git_log, args, config): """Create a bug for a change. Create a launchpad bug in a LP project, titled with the first line of the git commit message, with the content of the git_log prepended with the Gerrit review URL. Tag the bug with the name of the repository it came from. Returns link to the bug. """ # Determine what LP project to use prelude = '' project_name = args.project.rstrip('/') lp_project = projects.docimpact_target(project_name) if lp_project == 'unknown': prelude = ('\n\nDear documentation bug triager. This bug was created ' 'here because we did not know how to map the project name ' '"%s" to a launchpad project name. This indicates that the ' 'notify_impact config needs tweaks. You can ask the ' 'OpenStack infra team (#openstack-infra on freenode) for ' 'help if you need to.\n' % args.project) lp_project = 'openstack-manuals' lpconn = launchpad.Launchpad.login_with( 'Gerrit User Sync', uris.LPNET_SERVICE_ROOT, GERRIT_CACHE_DIR, credentials_file=GERRIT_CREDENTIALS, version='devel') if args.dryrun: actions = BugActionsDryRun(lpconn) else: actions = BugActionsReal(lpconn) lines_in_log = git_log.split('\n') bug_title = lines_in_log[4] bug_descr = args.change_url + prelude + '\n' + git_log project = lpconn.projects[lp_project] buglink = None author_class = None buginfo, buglink = actions.create(project, bug_title, bug_descr, args) # If the author of the merging patch matches our configured # subscriber lists, then subscribe the configured victims. for email_address in config.get('author_map', {}): email_re = re.compile('^Author:.*%s.*' % email_address) for line in bug_descr.split('\n'): m = email_re.match(line) if m: author_class = config['author_map'][email_address] if author_class: config = config.get('subscriber_map', {}).get(author_class, []) for subscriber in config: actions.subscribe(buginfo, subscriber) return buglink
def create_bug(git_log, args, config): """Create a bug for a change. Create a launchpad bug in a LP project, titled with the first line of the git commit message, with the content of the git_log prepended with the Gerrit review URL. Tag the bug with the name of the repository it came from. Returns link to the bug. """ # Determine what LP project to use prelude = ('\nDear bug triager. This bug was created since a ' 'commit was marked with DOCIMPACT.\n') project_name = args.project.rstrip('/') lp_project = projects.docimpact_target(project_name) if lp_project == 'unknown': prelude = ('\nDear bug triager. This bug was created since a ' 'commit was marked with DOCIMPACT.\n' 'Your project "%s" is set up so that we directly report ' 'the documentation bugs against it. If this needs ' 'changing, the docimpact-group option needs to be added ' 'for the project. You can ask the ' 'OpenStack infra team (#openstack-infra on freenode) for ' 'help if you need to.\n' % args.project) lp_project = project_name lpconn = launchpad.Launchpad.login_with( 'Gerrit User Sync', uris.LPNET_SERVICE_ROOT, GERRIT_CACHE_DIR, credentials_file=GERRIT_CREDENTIALS, version='devel') if args.dryrun: actions = BugActionsDryRun(lpconn) else: actions = BugActionsReal(lpconn) lines_in_log = git_log.split('\n') bug_title = lines_in_log[4] bug_descr = args.change_url + prelude + '\n' + git_log project = lpconn.projects[lp_project] buglink = None author_class = None buginfo, buglink = actions.create(project, bug_title, bug_descr, args) logger.info('Created a bug in project %(project)s with title "%(title)s": ' '%(buglink)s' % { 'project': project, 'title': bug_title, 'buglink': buglink }) # If the author of the merging patch matches our configured # subscriber lists, then subscribe the configured victims. for email_address in config.get('author_map', {}): email_re = re.compile('^Author:.*%s.*' % email_address) for line in bug_descr.split('\n'): m = email_re.match(line) if m: author_class = config['author_map'][email_address] if author_class: config = config.get('subscriber_map', {}).get(author_class, []) for subscriber in config: actions.subscribe(buginfo, subscriber) logger.info('Subscribed %(subscriber)s to bug %(buglink)s' % { 'subscriber': subscriber, 'buglink': buglink }) return buglink
def create_bug(git_log, args, config): """Create a bug for a change. Create a launchpad bug in a LP project, titled with the first line of the git commit message, with the content of the git_log prepended with the Gerrit review URL. Tag the bug with the name of the repository it came from. Returns link to the bug. """ # Determine what LP project to use prelude = ('\nDear bug triager. This bug was created since a ' 'commit was marked with DOCIMPACT.\n') project_name = args.project.rstrip('/') lp_project = projects.docimpact_target(project_name) if lp_project == 'unknown': prelude = ('\nDear bug triager. This bug was created since a ' 'commit was marked with DOCIMPACT.\n' 'Your project "%s" is set up so that we directly report ' 'the documentation bugs against it. If this needs ' 'changing, the docimpact-group option needs to be added ' 'for the project. You can ask the ' 'OpenStack infra team (#openstack-infra on freenode) for ' 'help if you need to.\n' % args.project) lp_project = project_name lpconn = launchpad.Launchpad.login_with( 'Gerrit User Sync', uris.LPNET_SERVICE_ROOT, GERRIT_CACHE_DIR, credentials_file=GERRIT_CREDENTIALS, version='devel') if args.dryrun: actions = BugActionsDryRun(lpconn) else: actions = BugActionsReal(lpconn) lines_in_log = git_log.split('\n') bug_title = lines_in_log[4] bug_descr = args.change_url + prelude + '\n' + git_log project = lpconn.projects[lp_project] buglink = None author_class = None buginfo, buglink = actions.create(project, bug_title, bug_descr, args) logger.info('Created a bug in project %(project)s with title "%(title)s": ' '%(buglink)s' % {'project': project, 'title': bug_title, 'buglink': buglink}) # If the author of the merging patch matches our configured # subscriber lists, then subscribe the configured victims. for email_address in config.get('author_map', {}): email_re = re.compile('^Author:.*%s.*' % email_address) for line in bug_descr.split('\n'): m = email_re.match(line) if m: author_class = config['author_map'][email_address] if author_class: config = config.get('subscriber_map', {}).get(author_class, []) for subscriber in config: actions.subscribe(buginfo, subscriber) logger.info('Subscribed %(subscriber)s to bug %(buglink)s' % {'subscriber': subscriber, 'buglink': buglink}) return buglink