From d76ce144f05592156e1b6f4f5a8b57123744f66f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 11:00:45 +0300 Subject: [PATCH 1/3] chore(deps): bump actions/download-artifact from 4 to 5 (#262) Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4 to 5. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3163c6c..791b1d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -73,7 +73,7 @@ jobs: pip install .[dev] - name: Download wheel artifact - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v5 with: name: commit-check_wheel path: dist From 1b8ff4e5aec33a2b88470529a62a4c5f40de00ba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Aug 2025 09:08:45 +0300 Subject: [PATCH 2/3] chore(deps): bump actions/checkout from 4 to 5 (#263) --- .github/workflows/codspeed.yml | 2 +- .github/workflows/main.yml | 6 +++--- .github/workflows/publish-package.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml index f4bbb59..9dea181 100644 --- a/.github/workflows/codspeed.yml +++ b/.github/workflows/codspeed.yml @@ -29,7 +29,7 @@ jobs: name: Run benchmarks runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/setup-python@v5 with: python-version: "3.13" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 791b1d7..a5a3f45 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,7 +20,7 @@ jobs: build: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/setup-python@v5 with: python-version: '3.x' @@ -64,7 +64,7 @@ jobs: os: ['windows-latest', 'ubuntu-24.04', 'macos-latest'] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/setup-python@v5 with: python-version: ${{ matrix.py }} @@ -86,7 +86,7 @@ jobs: docs: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 with: ref: ${{ github.head_ref }} # get current branch name - uses: actions/setup-python@v5 diff --git a/.github/workflows/publish-package.yml b/.github/workflows/publish-package.yml index 9dcac79..a607fe6 100644 --- a/.github/workflows/publish-package.yml +++ b/.github/workflows/publish-package.yml @@ -14,7 +14,7 @@ jobs: publish: runs-on: ubuntu-24.04 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 # use fetch --all for setuptools_scm to work with: fetch-depth: 0 From 3537653523fcc53f4144cdd43274be83e39aeb67 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 26 Aug 2025 01:17:57 +0300 Subject: [PATCH 3/3] fix: skip signoff check merge commits (#266) * Initial plan * Fix signoff check to skip merge commits like imperative check does Co-authored-by: shenxianpeng <3353385+shenxianpeng@users.noreply.github.com> * Fix main.py to pass commit_msg_file parameter to check_commit_signoff Co-authored-by: shenxianpeng <3353385+shenxianpeng@users.noreply.github.com> * chore: update by pre-commit run -a * fix: ensure commit message is not a merge commit --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: shenxianpeng <3353385+shenxianpeng@users.noreply.github.com> Co-authored-by: shenxianpeng --- commit_check/commit.py | 8 +++++ commit_check/main.py | 2 +- tests/commit_test.py | 71 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/commit_check/commit.py b/commit_check/commit.py index fccc5da..d9ef0ab 100644 --- a/commit_check/commit.py +++ b/commit_check/commit.py @@ -76,6 +76,14 @@ def check_commit_signoff(checks: list, commit_msg_file: str = "") -> int: return PASS commit_msg = read_commit_msg(commit_msg_file) + + # Extract the subject line (first line of commit message) + subject = commit_msg.split('\n')[0].strip() + + # Skip if merge commit + if subject.startswith('Merge'): + return PASS + commit_hash = get_commit_info("H") result = re.search(check['regex'], commit_msg) if result is None: diff --git a/commit_check/main.py b/commit_check/main.py index f81af48..e90202a 100644 --- a/commit_check/main.py +++ b/commit_check/main.py @@ -127,7 +127,7 @@ def main() -> int: if args.branch: check_results.append(branch.check_branch(checks)) if args.commit_signoff: - check_results.append(commit.check_commit_signoff(checks)) + check_results.append(commit.check_commit_signoff(checks, args.commit_msg_file)) if args.merge_base: check_results.append(branch.check_merge_base(checks)) if args.imperative: diff --git a/tests/commit_test.py b/tests/commit_test.py index 9a1235d..2cabfb3 100644 --- a/tests/commit_test.py +++ b/tests/commit_test.py @@ -143,6 +143,11 @@ def test_check_commit_signoff(mocker): m_print_suggestion = mocker.patch( f"{LOCATION}.print_suggestion" ) + # Ensure commit message is NOT a merge commit + mocker.patch( + "commit_check.commit.read_commit_msg", + return_value="feat: add new feature" + ) retval = check_commit_signoff(checks) assert retval == FAIL assert m_re_search.call_count == 1 @@ -179,6 +184,72 @@ def test_check_commit_signoff_with_empty_checks(mocker): assert m_re_match.call_count == 0 +@pytest.mark.benchmark +def test_check_commit_signoff_skip_merge_commit(mocker): + """Test commit signoff check skips merge commits.""" + checks = [{ + "check": "commit_signoff", + "regex": "Signed-off-by:", + "error": "Signed-off-by not found", + "suggest": "Use --signoff" + }] + + mocker.patch( + "commit_check.commit.read_commit_msg", + return_value="Merge branch 'feature/test' into main" + ) + + retval = check_commit_signoff(checks, MSG_FILE) + assert retval == PASS + + +@pytest.mark.benchmark +def test_check_commit_signoff_skip_merge_pr_commit(mocker): + """Test commit signoff check skips GitHub merge PR commits.""" + checks = [{ + "check": "commit_signoff", + "regex": "Signed-off-by:", + "error": "Signed-off-by not found", + "suggest": "Use --signoff" + }] + + mocker.patch( + "commit_check.commit.read_commit_msg", + return_value="Merge pull request #123 from user/feature\n\nAdd new feature" + ) + + retval = check_commit_signoff(checks, MSG_FILE) + assert retval == PASS + + +@pytest.mark.benchmark +def test_check_commit_signoff_still_fails_non_merge_without_signoff(mocker): + """Test commit signoff check still fails for non-merge commits without signoff.""" + checks = [{ + "check": "commit_signoff", + "regex": "Signed-off-by:", + "error": "Signed-off-by not found", + "suggest": "Use --signoff" + }] + + mocker.patch( + "commit_check.commit.read_commit_msg", + return_value="feat: add new feature\n\nThis adds a new feature" + ) + + m_print_error_message = mocker.patch( + f"{LOCATION}.print_error_message" + ) + m_print_suggestion = mocker.patch( + f"{LOCATION}.print_suggestion" + ) + + retval = check_commit_signoff(checks, MSG_FILE) + assert retval == FAIL + assert m_print_error_message.call_count == 1 + assert m_print_suggestion.call_count == 1 + + @pytest.mark.benchmark def test_check_imperative_pass(mocker): """Test imperative mood check passes for valid imperative mood."""