diff options
author | android-build-prod (mdb) <android-build-team-robot@google.com> | 2020-07-08 00:11:48 +0000 |
---|---|---|
committer | android-build-prod (mdb) <android-build-team-robot@google.com> | 2020-07-08 00:11:48 +0000 |
commit | 8d7550e7bdf0bcfc4bdd833e145341814dccce7c (patch) | |
tree | 6308b95ad785054d3ae5ed2a62972ba058ef0b7a | |
parent | d1cad50e5082c439c6df5806d3afb367be97e344 (diff) | |
parent | d7363ec0659ab50df745f305d098ada4ca0adb8a (diff) | |
download | repohooks-8d7550e7bdf0bcfc4bdd833e145341814dccce7c.tar.gz |
Snap for 6660490 from d7363ec0659ab50df745f305d098ada4ca0adb8a to sdk-release
Change-Id: I443b7e491b608468967f33947be2e72deb8dbf0d
-rw-r--r-- | rh/hooks.py | 2 | ||||
-rwxr-xr-x | rh/hooks_unittest.py | 42 |
2 files changed, 37 insertions, 7 deletions
diff --git a/rh/hooks.py b/rh/hooks.py index 223323a..7c13bf1 100644 --- a/rh/hooks.py +++ b/rh/hooks.py @@ -682,7 +682,7 @@ def check_commit_msg_relnote_for_current_txt(project, commit, desc, diff, filtered = _filter_diff( diff, - [r'^(public_plus_experimental_current|current)\.txt$'] + [r'(^|/)(public_plus_experimental_current|current)\.txt$'] ) # If the commit does not contain a change to *current.txt, then this repo # hook check no longer applies. diff --git a/rh/hooks_unittest.py b/rh/hooks_unittest.py index 4c44b21..373e09f 100755 --- a/rh/hooks_unittest.py +++ b/rh/hooks_unittest.py @@ -575,11 +575,16 @@ class BuiltinHooksTests(unittest.TestCase): def test_commit_msg_relnote_for_current_txt(self, _mock_check, _mock_run): """Verify the commit_msg_relnote_for_current_txt builtin hook.""" - diff_without_current_txt = ['foo.txt', + diff_without_current_txt = ['bar/foo.txt', 'foo.cpp', 'foo.java', - 'current.java'] + 'foo_current.java', + 'foo_current.txt', + 'baz/current.java', + 'baz/foo_current.txt'] diff_with_current_txt = diff_without_current_txt + ['current.txt'] + diff_with_subdir_current_txt = \ + diff_without_current_txt + ['foo/current.txt'] diff_with_experimental_current_txt = \ diff_without_current_txt + ['public_plus_experimental_current.txt'] # Check some good messages. @@ -611,7 +616,22 @@ class BuiltinHooksTests(unittest.TestCase): 'Bug: 1234'), ), files=diff_with_experimental_current_txt, - ) + ) + # Check some good messages. + self._test_commit_messages( + rh.hooks.check_commit_msg_relnote_for_current_txt, + True, + ( + 'subj\n\nRelnote: This is a release note\n', + 'subj\n\nRelnote: This is a release note.\n\nChange-Id: 1234', + ('subj\n\nRelnote: This is release note 1 with\n' + 'an incorrectly formatted second line.\n\n' + 'Relnote: "This is release note 2, and it\n' + 'contains a correctly formatted second line."\n' + 'Bug: 1234'), + ), + files=diff_with_subdir_current_txt, + ) # Check some good messages. self._test_commit_messages( rh.hooks.check_commit_msg_relnote_for_current_txt, @@ -628,7 +648,7 @@ class BuiltinHooksTests(unittest.TestCase): 'Bug: 1234'), ), files=diff_without_current_txt, - ) + ) # Check some bad messages. self._test_commit_messages( rh.hooks.check_commit_msg_relnote_for_current_txt, @@ -638,7 +658,7 @@ class BuiltinHooksTests(unittest.TestCase): 'subj\nBug: 12345\nChange-Id: 1234', ), files=diff_with_current_txt, - ) + ) # Check some bad messages. self._test_commit_messages( rh.hooks.check_commit_msg_relnote_for_current_txt, @@ -648,7 +668,17 @@ class BuiltinHooksTests(unittest.TestCase): 'subj\nBug: 12345\nChange-Id: 1234', ), files=diff_with_experimental_current_txt, - ) + ) + # Check some bad messages. + self._test_commit_messages( + rh.hooks.check_commit_msg_relnote_for_current_txt, + False, + ( + 'subj' + 'subj\nBug: 12345\nChange-Id: 1234', + ), + files=diff_with_subdir_current_txt, + ) def test_cpplint(self, mock_check, _mock_run): """Verify the cpplint builtin hook.""" |