Commit 95c3d88c authored by Romain Bouvier's avatar Romain Bouvier
Browse files

Add a --migrate-components switch. Default: no

- This allow the migration of bugzilla components to a gitlab label.
- Only enable it when you want migrate components. Lots of Xfce does not
have relevant components.
parent 7a44074e
......@@ -56,7 +56,7 @@ COMPONENT_MAP = {
def processbug(bgo, bzurl, instance, resolution, target, user_cache,
milestone_cache, bzbug):
milestone_cache, bzbug, migrate_components):
print("Processing bug #%d: %s" % (, bzbug.summary))
......@@ -221,17 +221,15 @@ def processbug(bgo, bzurl, instance, resolution, target, user_cache,
description = \
template.render_issue_description(bzurl, bzbug, desctext, user_cache)
# Add a "bugzilla" label on all imported bugs
labels = ['bugzilla']
# Only set "bugzilla' label when migrating. Labels present in bz are not revelant
# if bzbug.status == 'NEEDINFO':
# labels += [NEEDINFO_LABEL]
# if bzbug.component.lower() not in ('general', '.general', target.product):
# l = COMPONENT_MAP.get(bzbug.component, None)
# if l is not None:
# labels.append(l)
# else:
# labels.append('5. {}'.format(bzbug.component.title()))
if migrate_components:
if bzbug.component.lower() not in ('general', '.general', target.product):
# for kw in bzbug.keywords:
# if kw in KEYWORD_MAP:
......@@ -253,8 +251,11 @@ def processbug(bgo, bzurl, instance, resolution, target, user_cache,
# Assign bug to actual account if exists
print("bz issue assigned to {}".format(bzbug.assigned_to))
assignee = user_cache[bzbug.assigned_to]
print("Assign issue to {} if possible".format(assignee))
if assignee and is not None:
print("Assign issue to {}".format(assignee))
issue.assignee_id =
print("Migrating comments: ")
......@@ -297,10 +298,14 @@ def processbug(bgo, bzurl, instance, resolution, target, user_cache,
for cc_email in itertools.chain(, [bzbug.creator]):
subscriber = user_cache[cc_email]
if subscriber and is not None:
print("issue cc to {}".format(subscriber))
print("is subscribe ok ?")
except gitlab.GitlabSubscribeError as e:
if e.response_code in (201, 304):
print("Response code : {}".format(e.response_code))
print("Response : {}".format(e))
# 201 == workaround for python-gitlab bug
# 304 == already subscribed
......@@ -364,6 +369,8 @@ def options():
help="import for rather than GNOME")
parser.add_argument('--resolved', action='store_true',
help="import resolved bugs (default: no)")
parser.add_argument('--migrate-components', action='store_true',
help="import bugzilla components (=gitlab label) (default: no)")
return parser.parse_args()
......@@ -429,6 +436,10 @@ def main():
if args.only_import:
if args.migrate_components:
print("Connecting to %s" % bzurl)
if args.bz_user and args.bz_password:
bgo = bugzilla.Bugzilla(bzurl, args.bz_user, args.bz_password)
......@@ -466,7 +477,7 @@ def main():
#sys.stdout.write(' SKIPPED!')
processbug(bgo, bzurl, instance, bzresolution, target, user_cache,
milestone_cache, bzbug)
milestone_cache, bzbug, migrate_components)
if os.path.exists('users_cache'):
print('IMPORTANT: Remove the file \'users_cache\' after use, it \
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment