Accept "Fix: " as a bug line am: e745062e33 Original change: https://android-review.googlesource.com/c/platform/tools/repohooks/+/3295916 Change-Id: I9507260024ec8a1acc27c4a1b519a85d4d054061 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/rh/hooks.py b/rh/hooks.py index 5dc7911..8588f93 100644 --- a/rh/hooks.py +++ b/rh/hooks.py
@@ -497,13 +497,12 @@ def check_commit_msg_bug_field(project, commit, desc, _diff, options=None): - """Check the commit message for a 'Bug:' line.""" - field = 'Bug' - regex = fr'^{field}: (None|[0-9]+(, [0-9]+)*)$' + """Check the commit message for a 'Bug:' or 'Fix:' line.""" + regex = r'^(Bug|Fix): (None|[0-9]+(, [0-9]+)*)$' check_re = re.compile(regex) if options.args(): - raise ValueError(f'commit msg {field} check takes no options') + raise ValueError('commit msg Bug check takes no options') found = [] for line in desc.splitlines(): @@ -512,13 +511,13 @@ if not found: error = ( - f'Commit message is missing a "{field}:" line. It must match the\n' + 'Commit message is missing a "Bug:" line. It must match the\n' f'following case-sensitive regex:\n\n {regex}' ) else: return None - return [rh.results.HookResult(f'commit msg: "{field}:" check', + return [rh.results.HookResult('commit msg: "Bug:" check', project, commit, error=error)]
diff --git a/rh/hooks_unittest.py b/rh/hooks_unittest.py index 1fc0c15..a54e24f 100755 --- a/rh/hooks_unittest.py +++ b/rh/hooks_unittest.py
@@ -473,6 +473,7 @@ rh.hooks.check_commit_msg_bug_field, True, ( 'subj\n\nBug: 1234\n', 'subj\n\nBug: 1234\nChange-Id: blah\n', + 'subj\n\nFix: 1234\n', )) # Check some bad messages. @@ -483,6 +484,7 @@ 'subj\n\nBUG: 1234\n', 'subj\n\nBug: N/A\n', 'subj\n\nBug:\n', + 'subj\n\nFIX=1234\n', )) def test_commit_msg_changeid_field(self, _mock_check, _mock_run):