diff --git a/main.py b/main.py index 616744c..ba28722 100755 --- a/main.py +++ b/main.py @@ -21,6 +21,7 @@ print(f'Commit message: {message}') files = githooks.get_commit_files() + repo = githooks.get_repo() print(f'Checking {githooks.get_event()} modified files:') print(' ' + '\n '.join(files['M'])) print(f'Checking {githooks.get_event()} new files:') @@ -28,7 +29,7 @@ retval = 0 - retval += githooks.check_commit_msg(message, files['M'] + files['A']) + retval += githooks.check_commit_msg(message, files['M'] + files['A'], repo) if githooks._is_pull_request(): retval += githooks.check_do_not_merge(files['M']) diff --git a/main/githooks.py b/main/githooks.py index d3ee61c..d795068 100755 --- a/main/githooks.py +++ b/main/githooks.py @@ -833,7 +833,7 @@ def check_content(files): return retval -def check_commit_msg(message, files): +def check_commit_msg(message, files, repo): '''Check commit message (and file size). Abort if file size exceeds hard (github.com) limit. @@ -850,9 +850,9 @@ def check_commit_msg(message, files): # Not checking for JIRA or large file in commit message generated by github return 0 - # if re.match(r'^ccdc-opensource', repo): - # # Do not check for JIRA in opensource repo as we don't want to require external contributors to do this - # return 0 + if re.match(r'^ccdc-opensource/', repo): + # Do not check for JIRA in opensource repo as we don't want to require external contributors to do this + return 0 if NO_JIRA_MARKER not in message: if jira_id_pattern.search(message) is None: @@ -899,7 +899,7 @@ def _test(input, is_jira=True): class TestCheckCommitMessage(unittest.TestCase): def test_various_strings(self): def _test(input, is_good=True): - rc = check_commit_msg(input, []) + rc = check_commit_msg(input, [], "fake/repo") self.assertEqual(rc == 0, is_good) _test('ABC-1234') _test('Some changes for ABC-1234 ticket') @@ -944,6 +944,6 @@ def commit_msg_hook(): commit_message = Path(sys.argv[1]).read_text() print(' Check commit message ...') - retval += check_commit_msg(commit_message, files['M'] + files['A']) + retval += check_commit_msg(commit_message, files['M'] + files['A'], get_repo()) return retval