From d41fac3ea1ebe2d4adde47311f04484b5804a58b Mon Sep 17 00:00:00 2001 From: Manish Maharjan Date: Thu, 7 May 2026 12:34:06 +0100 Subject: [PATCH 1/3] SYS-8303 add exception for co-pilot autofix --- README.md | 4 ++-- main/githooks.py | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b9b08b9..36a611a 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ The commit will be flagged if it includes certain text files with: * Certain C++ #include patterns and std::exception The commit will also be flagged if the commit message does not include a Jira -ID (unless marked with NO_JIRA), or if the size of new or modiffied files -exceeds a threshold. +ID (unless marked with NO_JIRA or a Copilot Autofix co-author line), or if the +size of new or modiffied files exceeds a threshold. # Github action diff --git a/main/githooks.py b/main/githooks.py index d795068..8d54b99 100755 --- a/main/githooks.py +++ b/main/githooks.py @@ -25,6 +25,11 @@ LARGE_FILE_MARKER = 'LARGE_FILE' # No jira marker in commit message NO_JIRA_MARKER = 'NO_JIRA' +# Copilot Autofix co-author in commit message description +COPILOT_AUTOFIX = re.compile( + r'^Co-authored-by:\s+.*<\d+\+Copilot@users\.noreply\.github\.com>$', + re.MULTILINE, +) # A marker to represent it's a change we don't want to commit DO_NOT_COMMIT = 'do not' + ' commit' # Check file content if it has these extensions @@ -854,11 +859,16 @@ def check_commit_msg(message, files, 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: - _fail('Every commit should contain a Jira issue ID or the text ' - f'{NO_JIRA_MARKER}') - return 1 + if ( + NO_JIRA_MARKER not in message + and COPILOT_AUTOFIX.search(message) is None + and jira_id_pattern.search(message) is None + ): + _fail( + 'Every commit should contain a Jira issue ID, ' + f'{NO_JIRA_MARKER}, or be a Copilot Autofix commit' + ) + return 1 for filename in files: size = Path(filename).stat().st_size / 1024**2 @@ -904,6 +914,10 @@ def _test(input, is_good=True): _test('ABC-1234') _test('Some changes for ABC-1234 ticket') _test('Trivial change NO_JIRA') + _test( + 'Trivial change\n\n' + 'Co-authored-by: Copilot Autofix powered by AI' + ) _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") From fffeab380d15e0c64ec5e3a3e315a999605bbea8 Mon Sep 17 00:00:00 2001 From: Manish Maharjan Date: Thu, 7 May 2026 12:37:00 +0100 Subject: [PATCH 2/3] SYS-8303 update test with email address --- main/githooks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/githooks.py b/main/githooks.py index 8d54b99..b627e30 100755 --- a/main/githooks.py +++ b/main/githooks.py @@ -916,7 +916,8 @@ def _test(input, is_good=True): _test('Trivial change NO_JIRA') _test( 'Trivial change\n\n' - 'Co-authored-by: Copilot Autofix powered by AI' + 'Co-authored-by: Copilot Autofix powered by AI ' + '<175728472+Copilot@users.noreply.github.com>' ) _test("Merge branch 'main' into my_branch") _test("Merge branch 'branch_1' into branch_2") From 2b1bb8b1ed30ce6ab839e1b984cb0b88dea955ec Mon Sep 17 00:00:00 2001 From: Manish Maharjan Date: Thu, 7 May 2026 12:46:21 +0100 Subject: [PATCH 3/3] SYS-8303 rename copilot_autofix variable --- README.md | 2 +- main/githooks.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 36a611a..f38d38c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The commit will be flagged if it includes certain text files with: The commit will also be flagged if the commit message does not include a Jira ID (unless marked with NO_JIRA or a Copilot Autofix co-author line), or if the -size of new or modiffied files exceeds a threshold. +size of new or modified files exceeds a threshold. # Github action diff --git a/main/githooks.py b/main/githooks.py index b627e30..70eb012 100755 --- a/main/githooks.py +++ b/main/githooks.py @@ -26,7 +26,7 @@ # No jira marker in commit message NO_JIRA_MARKER = 'NO_JIRA' # Copilot Autofix co-author in commit message description -COPILOT_AUTOFIX = re.compile( +copilot_autofix_coauthor_pattern = re.compile( r'^Co-authored-by:\s+.*<\d+\+Copilot@users\.noreply\.github\.com>$', re.MULTILINE, ) @@ -861,7 +861,7 @@ def check_commit_msg(message, files, repo): if ( NO_JIRA_MARKER not in message - and COPILOT_AUTOFIX.search(message) is None + and copilot_autofix_coauthor_pattern.search(message) is None and jira_id_pattern.search(message) is None ): _fail(