diff options
author | Nick Anthony <nickanthony@google.com> | 2020-06-19 19:05:12 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-19 19:05:12 +0000 |
commit | 9326f1e03e13f714d4b08cc70d5256779a093fe1 (patch) | |
tree | 6308b95ad785054d3ae5ed2a62972ba058ef0b7a | |
parent | 3ccf437583f7dcc8d53301256c6effdea865e9e3 (diff) | |
parent | d7363ec0659ab50df745f305d098ada4ca0adb8a (diff) | |
download | repohooks-9326f1e03e13f714d4b08cc70d5256779a093fe1.tar.gz |
Fix regex in commit_msg_relnote_for_current_txt repo hook am: d7363ec065ndk-sysroot-r21
Original change: https://android-review.googlesource.com/c/platform/tools/repohooks/+/1344736
Change-Id: I38cfd364bf23c3ac851d66b4a6d6f87f62bcc9ce
-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.""" |