PRESUBMIT: add a warning for crbug links w/o https://
Our code search doesn't linkify crbug[.com] if they are
not prefixed with http[s]:// (e.g. [1]). This CL adds a
warning on upload that this is happening and suggests
prefixing https://, since it seems like we are not going
to be able to linkify them automatically in CS anytime
soon (see bug).
It looks a bit like:
** Presubmit Warnings **
Found unprefixed crbug.com URL(s), consider prepending https://
ui/ozone/platform/drm/gpu/gbm_buffer.h:107 // TODO(mcasas): crbug.com
ui/ozone/platform/drm/gpu/gbm_buffer.h:108 // TODO(mcasas): crbug/123
[1] https://cs.chromium.org/chromium/src/BUILD.gn?type=cs&q=crbug.com&sq=package:chromium&l=65
Bug: 762061
Change-Id: Ib58bc6b58dfa61a7bf421b0ed55184705cee767c
Reviewed-on: https://chromium-review.googlesource.com/822973
Reviewed-by: Jochen Eisinger <[email protected]>
Commit-Queue: Miguel Casas <[email protected]>
Cr-Commit-Position: refs/heads/master@{#524073}
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index a18d9234..bb22f8c 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -1288,5 +1288,22 @@
self.assertEqual([], errors)
+class CrbugUrlFormatTest(unittest.TestCase):
+
+ def testCheckCrbugLinksHaveHttps(self):
+ input_api = MockInputApi()
+ input_api.files = [
+ MockFile('somewhere/file.cc',
+ ['// TODO(developer): crbug.com should be linkified',
+ '// TODO(developer): (crbug.com) should be linkified',
+ '// TODO(developer): crbug/123 should be well formed',
+ '// TODO(developer): http://crbug.com it\'s OK',
+ '// TODO(developer): https://crbug.com is just great']),
+ ]
+
+ warnings = PRESUBMIT._CheckCrbugLinksHaveHttps(input_api, MockOutputApi())
+ self.assertEqual(1, len(warnings))
+
+
if __name__ == '__main__':
unittest.main()