diff options
| -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.""" |
