From 407e5e7b66ead00b330cc1adb281729bac8217df Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Thu, 20 Apr 2023 23:39:34 +0000 Subject: [PATCH] Show error on Fixes: and suggest Fixed: The Bug: syntax is well known as a way of tagging bugs in a commit message, at least partially because when it is missing there is a presubmit warning suggesting that it be used. The Fixed: syntax is less well known because there is no such reminder. And, if somebody types "Fixes: " instead of "Fixed: " there is no error. Therefore it is not surprising that "Fixes: " was used seven times in the last 10,000 commits. See crrev.com/c/4416218 for one example. This change adds both a reminder that Fixed: exists as well as an error if Fixes: is used. Fixed: 1434702 Change-Id: Id940d0af5cfea206ee923fbb779bf686b34c5f33 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4436316 Reviewed-by: Aravind Vasudevan Commit-Queue: Bruce Dawson --- presubmit_canned_checks.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 41594c63f..3f7ac0cdd 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -71,16 +71,24 @@ _CORP_LINK_KEYWORD = '.corp.google' def CheckChangeHasBugField(input_api, output_api): """Requires that the changelist have a Bug: field.""" bugs = input_api.change.BugsFromDescription() + results = [] if bugs: if any(b.startswith('b/') for b in bugs): - return [ + results.append( output_api.PresubmitNotifyResult( - 'Buganizer bugs should be prefixed with b:, not b/.') - ] - return [] + 'Buganizer bugs should be prefixed with b:, not b/.')) + else: + results.append( + output_api.PresubmitNotifyResult( + 'If this change has an associated bug, add Bug: [bug number] or ' + 'Fixed: [bug number].')) + + if 'Fixes' in input_api.change.GitFootersFromDescription(): + results.append( + output_api.PresubmitError( + 'Fixes: is the wrong footer tag, use Fixed: instead.')) + return results - return [output_api.PresubmitNotifyResult( - 'If this change has an associated bug, add Bug: [bug number].')] def CheckChangeHasNoUnwantedTags(input_api, output_api): UNWANTED_TAGS = {