← 输入框|github.com|刷新
Skip to content

fix: give CC017 advice that works before the commit exists - #685

Merged
shenxianpeng merged 1 commit into
mainfrom
fix/ai-author-advice-before-commit
Nov 10, 2026
Merged

shenxianpeng merged 1 commit into
mainfrom
fix/ai-author-advice-before-commit

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

What

CC017 rejects a commit whose author is an AI tool. For a message that is not committed yet (the commit-msg hook, or a piped message), it suggested git commit --amend --reset-author. That advice is wrong there:

  • The commit does not exist yet, so --amend rewrites the commit before it.
  • --reset-author records the identity from the config or GIT_AUTHOR_* again, which is the same AI identity, so the commit still fails.

For a pending message, the suggestion now says to set user.name and user.email (or unset GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL) first. The Action pipes existing pull request commits in the same way, so the suggestion ends with the --amend --reset-author step for those. With --rev or HEAD the advice is unchanged.

Before vs after

$ printf 'feat: add x\n' | GIT_AUTHOR_NAME=Claude GIT_AUTHOR_EMAIL=noreply@anthropic.com commit-check -m

Before:

✖ CC017 ai-author failed: Claude <noreply@anthropic.com>
  An AI tool is the commit author: Claude Code
  Suggest: Author the commit yourself: git commit --amend --reset-author

After:

✖ CC017 ai-author failed: Claude <noreply@anthropic.com>
  An AI tool is the commit author: Claude Code
  Suggest: Commit as yourself: set git config user.name and user.email to your own, and unset GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL if a tool set them; a commit that already exists then needs git commit --amend --reset-author

Tests

test_a_message_not_yet_committed_is_not_told_to_amend covers stdin and a message file. The existing tests for --rev and HEAD still expect the old text.

@shenxianpeng
shenxianpeng requested a review from a team as a code owner November 10, 2026 05:47
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ec9a05ca-2358-4f96-8b9c-0df15aff7f2f
Commits

Reviewing files that changed from the base of the PR and between 878482c and f314115.

Files selected for processing: 2

  • commit_check/engine.py
  • tests/engine_test.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the bug Something isn't working label Nov 10, 2026
@shenxianpeng shenxianpeng self-assigned this Nov 10, 2026
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (878482c) to head (f314115).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #685   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines         2529      2533    +4     
  Branches       491       492    +1     
=========================================
+ Hits          2529      2533    +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

In the commit-msg hook, or for a piped message, CC017 suggested
git commit --amend --reset-author. The commit does not exist yet, so
--amend would rewrite the previous one, and --reset-author records the
same AI identity again. It now says to set user.name and user.email (or
unset GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL) first.
@shenxianpeng
shenxianpeng force-pushed the fix/ai-author-advice-before-commit branch from 41d08a2 to f314115 Compare November 10, 2026 05:53
@sonarqubecloud

Copy link
Copy Markdown

@shenxianpeng
shenxianpeng merged commit 928b27d into main Nov 10, 2026
32 checks passed
@shenxianpeng
shenxianpeng deleted the fix/ai-author-advice-before-commit branch November 10, 2026 05:59
@codspeed

codspeed Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 133 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 684 untouched benchmarks
⏩ 131 skipped benchmarks1


Comparing fix/ai-author-advice-before-commit (f314115) with main (c58b1ea)2

Open in CodSpeed

Footnotes

  1. 131 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (878482c) during the generation of this report, so c58b1ea was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant