From ac6ab827e1059ca2593a64fc56b37b2dbab38b89 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Mon, 3 Jun 2019 11:06:03 +0200 Subject: [PATCH] History changes might contain extraneous ', ' at the beginning or the end, ignore them --- bugbug/bug_snapshot.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bugbug/bug_snapshot.py b/bugbug/bug_snapshot.py index d20ce8dd..ead00800 100644 --- a/bugbug/bug_snapshot.py +++ b/bugbug/bug_snapshot.py @@ -553,6 +553,10 @@ def rollback(bug, when=None, do_assert=False): obj = bug if change["added"]: + # https://bugzilla.mozilla.org/show_bug.cgi?id=1556178 + if change["added"].startswith(", "): + change["added"] = change["added"][2:] + for to_remove in change["added"].split(", "): if any( to_remove.startswith(s) @@ -597,6 +601,10 @@ def rollback(bug, when=None, do_assert=False): if bug["id"] == 1_342_178: continue + # https://bugzilla.mozilla.org/show_bug.cgi?id=1556178 + if change["removed"].startswith(", "): + change["removed"] = change["removed"][2:] + for to_add in change["removed"].split(", "): name, status, requestee = parse_flag_change(to_add) @@ -616,8 +624,12 @@ def rollback(bug, when=None, do_assert=False): if field in bug and isinstance(bug[field], list): if change["added"]: - if field == "see_also" and change["added"].endswith(", "): - change["added"] = change["added"][:-2] + # https://bugzilla.mozilla.org/show_bug.cgi?id=1556178 + if field in ["cc", "see_also"]: + if change["added"].endswith(", "): + change["added"] = change["added"][:-2] + if change["added"].startswith(", "): + change["added"] = change["added"][2:] for to_remove in change["added"].split(", "): if field in FIELD_TYPES: @@ -633,6 +645,10 @@ def rollback(bug, when=None, do_assert=False): ) if change["removed"]: + # https://bugzilla.mozilla.org/show_bug.cgi?id=1556178 + if field == "depends_on" and change["removed"].startswith(", "): + change["removed"] = change["removed"][2:] + for to_add in change["removed"].split(", "): if field in FIELD_TYPES: to_add = FIELD_TYPES[field](to_add)