Conversation
…heck for open source contributions NO_JIRA
There was a problem hiding this comment.
Pull request overview
This PR enables the exemption of JIRA ID requirements for commits to ccdc-opensource repositories to accommodate external contributors. The changes uncomment previously commented-out logic that checks the repository name and bypasses JIRA validation for opensource repos. The implementation adds a repo parameter to the check_commit_msg function and updates all call sites to pass the repository name obtained via get_repo().
Changes:
- Added
repoparameter tocheck_commit_msgfunction to enable repository-specific validation logic - Uncommented and activated the logic that exempts ccdc-opensource repositories from JIRA ID requirements
- Updated all function call sites in both
main.pyandgithooks.pyto pass the repository parameter
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| main/githooks.py | Added repo parameter to check_commit_msg function signature, uncommented opensource repo exemption logic with improved regex pattern (added trailing slash), and updated test and commit_msg_hook call sites |
| main.py | Retrieved repo name using get_repo() and passed it to check_commit_msg function call |
Comments suppressed due to low confidence (2)
main/githooks.py:915
- The test cases do not cover the new opensource repository exception logic. Consider adding test cases that verify:
- A commit without a JIRA ID is rejected for a regular repo (e.g., "fake/repo")
- A commit without a JIRA ID is accepted for an opensource repo (e.g., "ccdc-opensource/test-repo")
This will ensure the new conditional logic works correctly and prevent future regressions.
class TestCheckCommitMessage(unittest.TestCase):
def test_various_strings(self):
def _test(input, is_good=True):
rc = check_commit_msg(input, [], "fake/repo")
self.assertEqual(rc == 0, is_good)
_test('ABC-1234')
_test('Some changes for ABC-1234 ticket')
_test('Trivial change NO_JIRA')
_test("Merge branch 'main' into my_branch")
_test("Merge branch 'branch_1' into branch_2")
_test("Merge branch 'jira_pyapi_123_abc' of github.com:ccdc-confidential/cpp-apps-main into jira_pyapi_123_abc")
_test("Merge commit 'abcdef' into jira_mer_123_abc")
_test("Merge remote-tracking branch 'origin/release/2022.1' into merge_from_release")
_test("Merge pull request #1 from patch-1")
_test('I forgot to add the jira marker!', False)
_test('Close but no cigar abc-1234', False)
main/githooks.py:844
- The docstring for this function should be updated to document the new 'repo' parameter. Consider adding a parameter description that explains it should be in the format "owner/repo" and is used to determine if JIRA checks should be bypassed for opensource repositories.
def check_commit_msg(message, files, repo):
'''Check commit message (and file size).
Abort if file size exceeds hard (github.com) limit.
If file size exceeds our soft (internal) limit, flag up if commit message
does not contain required marker.
'''
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This has been properly tested now