|
25 | 25 | LARGE_FILE_MARKER = 'LARGE_FILE' |
26 | 26 | # No jira marker in commit message |
27 | 27 | NO_JIRA_MARKER = 'NO_JIRA' |
| 28 | +# Copilot Autofix co-author in commit message description |
| 29 | +copilot_autofix_coauthor_pattern = re.compile( |
| 30 | + r'^Co-authored-by:\s+.*<\d+\+Copilot@users\.noreply\.github\.com>$', |
| 31 | + re.MULTILINE, |
| 32 | +) |
28 | 33 | # A marker to represent it's a change we don't want to commit |
29 | 34 | DO_NOT_COMMIT = 'do not' + ' commit' |
30 | 35 | # Check file content if it has these extensions |
@@ -854,11 +859,16 @@ def check_commit_msg(message, files, repo): |
854 | 859 | # Do not check for JIRA in opensource repo as we don't want to require external contributors to do this |
855 | 860 | return 0 |
856 | 861 |
|
857 | | - if NO_JIRA_MARKER not in message: |
858 | | - if jira_id_pattern.search(message) is None: |
859 | | - _fail('Every commit should contain a Jira issue ID or the text ' |
860 | | - f'{NO_JIRA_MARKER}') |
861 | | - return 1 |
| 862 | + if ( |
| 863 | + NO_JIRA_MARKER not in message |
| 864 | + and copilot_autofix_coauthor_pattern.search(message) is None |
| 865 | + and jira_id_pattern.search(message) is None |
| 866 | + ): |
| 867 | + _fail( |
| 868 | + 'Every commit should contain a Jira issue ID, ' |
| 869 | + f'{NO_JIRA_MARKER}, or be a Copilot Autofix commit' |
| 870 | + ) |
| 871 | + return 1 |
862 | 872 |
|
863 | 873 | for filename in files: |
864 | 874 | size = Path(filename).stat().st_size / 1024**2 |
@@ -904,6 +914,11 @@ def _test(input, is_good=True): |
904 | 914 | _test('ABC-1234') |
905 | 915 | _test('Some changes for ABC-1234 ticket') |
906 | 916 | _test('Trivial change NO_JIRA') |
| 917 | + _test( |
| 918 | + 'Trivial change\n\n' |
| 919 | + 'Co-authored-by: Copilot Autofix powered by AI ' |
| 920 | + '<175728472+Copilot@users.noreply.github.com>' |
| 921 | + ) |
907 | 922 | _test("Merge branch 'main' into my_branch") |
908 | 923 | _test("Merge branch 'branch_1' into branch_2") |
909 | 924 | _test("Merge branch 'jira_pyapi_123_abc' of github.com:ccdc-confidential/cpp-apps-main into jira_pyapi_123_abc") |
|
0 commit comments