Update check_commit_msg_bug_field style
Other hooks have `field = '...'` in them.
For https://android-review.git.corp.google.com/c/platform/tools/repohooks/+/3295916/comment/e6779855_42bc8391/
Bug: 371923047
Test: rh/hooks_unittest.py
Change-Id: Ib8932f597df7f9988ac5c393c2845f5e5db3338d
Reviewed-on: https://android-review.googlesource.com/c/platform/tools/repohooks/+/3432026
Reviewed-by: Mike Frysinger <[email protected]>
Autosubmit: Li-Yu Yu <[email protected]>
Open-Source-Licensing: Lint 🤖 <[email protected]>
Performance: CrystalBall Performance Presubmit <[email protected]>
Presubmit-Verified: Treehugger Robot <[email protected]>
Lint: Lint 🤖 <[email protected]>
diff --git a/rh/hooks.py b/rh/hooks.py
index ec8b69c..6bdf344 100644
--- a/rh/hooks.py
+++ b/rh/hooks.py
@@ -499,11 +499,12 @@
def check_commit_msg_bug_field(project, commit, desc, _diff, options=None):
"""Check the commit message for a 'Bug:' or 'Fix:' line."""
+ field = 'Bug'
regex = r'^(Bug|Fix): (None|[0-9]+(, [0-9]+)*)$'
check_re = re.compile(regex)
if options.args():
- raise ValueError('commit msg Bug check takes no options')
+ raise ValueError(f'commit msg {field} check takes no options')
found = []
for line in desc.splitlines():
@@ -512,13 +513,13 @@
if not found:
error = (
- 'Commit message is missing a "Bug:" line. It must match the\n'
+ f'Commit message is missing a "{field}:" line. It must match the\n'
f'following case-sensitive regex:\n\n {regex}'
)
else:
return None
- return [rh.results.HookResult('commit msg: "Bug:" check',
+ return [rh.results.HookResult(f'commit msg: "{field}:" check',
project, commit, error=error)]