From b09541191487afcfdc2f2ce21604c954dc07d371 Mon Sep 17 00:00:00 2001 From: Jordan Layfield Date: Tue, 24 Feb 2026 16:48:02 +0000 Subject: [PATCH 1/3] Refactor check_commit_msg to include repo parameter and adjust JIRA check for open source contributions NO_JIRA --- main/githooks.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main/githooks.py b/main/githooks.py index d3ee61c..0e20d31 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 From 7f125a4db51689f7ec20d548a8b9b1d6eb897154 Mon Sep 17 00:00:00 2001 From: Jordan Layfield Date: Tue, 24 Feb 2026 16:52:41 +0000 Subject: [PATCH 2/3] Update JIRA check in check_commit_msg to exclude open source repositories NO_JIRA --- main/githooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/githooks.py b/main/githooks.py index 0e20d31..d795068 100755 --- a/main/githooks.py +++ b/main/githooks.py @@ -850,7 +850,7 @@ def check_commit_msg(message, files, repo): # Not checking for JIRA or large file in commit message generated by github return 0 - if re.match(r'^ccdc-opensource', repo): + 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 From 05faaa36cc9a58b31353cf908beffb5da290ae0b Mon Sep 17 00:00:00 2001 From: Jordan Layfield Date: Tue, 24 Feb 2026 16:59:35 +0000 Subject: [PATCH 3/3] Pass repository parameter to check_commit_msg for improved context NO_JIRA --- main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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'])