Update bug field repohook
Cusky now uses b/<id> instead of b:<id>, which is used by ChromeOS. We
need to update the repohook that checks the bug field to reflect this.
BUG=b/162410910
TEST=pre-upload_unittest.py and tested on this commit message
RELEASE_NOTE=None
Change-Id: Ic443c005247d43d212415d1aff18b274001af8e0
diff --git a/pre-upload.py b/pre-upload.py
index ec1ce24..d71753c 100755
--- a/pre-upload.py
+++ b/pre-upload.py
@@ -800,10 +800,17 @@
"""Check for a correctly formatted 'BUG=' field in the commit message."""
SEE_ALSO = 'Please review the documentation:\n%s' % (DOC_COMMIT_MSG_URL,)
- OLD_BUG_RE = r'\nBUG=.*chromium-os'
+ OLD_BUG_RE = r'\nBUG=b:\d+'
if re.search(OLD_BUG_RE, _get_commit_desc(commit)):
- msg = ('The chromium-os bug tracker is now deprecated. Please use\n'
- 'the chromium tracker in your BUG= line now.')
+ msg = ('The old bug format b:<id> for buganizer bugs is deprecated.\n'
+ 'Please use the new format b/<id> in your BUG= line now.')
+ return HookFailure(msg)
+
+ OLD_CHROMIUM_RE = r'\nBUG=chromium:\d+'
+ if re.search(OLD_CHROMIUM_RE, _get_commit_desc(commit)):
+ msg = ('The chromium: tracker is no longer supported.\n'
+ 'Please provide a buganinzer id in the form b/<id> '
+ 'instead in your BUG= line now.')
return HookFailure(msg)
# Android internal and external projects use "Bug: " to track bugs in
@@ -821,12 +828,11 @@
'BUG=None\n%s' % (SEE_ALSO,))
return HookFailure(msg)
else:
- BUG_RE = r'\nBUG=([Nn]one|(chromium|b):\d+)'
+ BUG_RE = r'\nBUG=([Nn]one|b\/\d+)'
if not re.search(BUG_RE, _get_commit_desc(commit)):
msg = ('Changelist description needs BUG field (after first line):\n'
'Examples:\n'
- 'BUG=chromium:9999 (for public tracker)\n'
- 'BUG=b:9999 (for buganizer)\n'
+ 'BUG=b/9999 (for buganizer)\n'
'BUG=None\n%s' % (SEE_ALSO,))
return HookFailure(msg)
diff --git a/pre-upload_unittest.py b/pre-upload_unittest.py
index c3886ba..b68967d 100755
--- a/pre-upload_unittest.py
+++ b/pre-upload_unittest.py
@@ -11,8 +11,7 @@
import datetime
import os
import sys
-
-import mock
+from unittest import mock
import errors
@@ -1082,8 +1081,7 @@
def testNormal(self):
"""Accept a commit message w/a valid BUG."""
- self.assertMessageAccepted('\nBUG=chromium:1234\n', self.CROS_PROJECT)
- self.assertMessageAccepted('\nBUG=b:1234\n', self.CROS_PROJECT)
+ self.assertMessageAccepted('\nBUG=b/1234\n', self.CROS_PROJECT)
self.assertMessageAccepted('\nBug: 1234\n', self.AOSP_PROJECT)
self.assertMessageAccepted('\nBug:1234\n', self.AOSP_PROJECT)
@@ -1119,9 +1117,9 @@
def testOldTrackers(self):
"""Reject commit messages using old trackers."""
- self.assertMessageRejected('\nBUG=chrome-os-partner:1234\n',
+ self.assertMessageRejected('\nBUG=b:1234\n',
self.CROS_PROJECT)
- self.assertMessageRejected('\nBUG=chromium-os:1234\n', self.CROS_PROJECT)
+ self.assertMessageRejected('\nBUG=chromium:1234\n', self.CROS_PROJECT)
def testNoTrackers(self):
"""Reject commit messages w/invalid trackers."""