Skip to content

Feature/add ai fix commit#385

Draft
shenxianpeng wants to merge 2 commits intomainfrom
feature/add-ai-fix-commit
Draft

Feature/add ai fix commit#385
shenxianpeng wants to merge 2 commits intomainfrom
feature/add-ai-fix-commit

Conversation

@shenxianpeng
Copy link
Member

No description provided.

Introduce rule-driven commit message auto-repair with zero new runtime
dependencies. When --fix is passed alongside --message, cchk validates
the commit, proposes a corrected message, and prompts y/N before amending.
--yes skips the prompt (useful in CI and pre-commit hooks).

New module: commit_check/fixer.py
- CommitFixer.fix() applies transforms in canonical order:
  allow_wip_commits → subject_imperative → subject_capitalized → require_signed_off_by
- _to_imperative() converts past/present verb forms to imperative using
  a lookup table (simplified→simplify) plus suffix rules (-ed, -ing, -s/-es)
- FixResult tracks which checks were fixed and which remain unfixable

Engine updates (engine.py):
- CheckResult dataclass for per-check result tracking
- validate_all_detailed() returns List[CheckResult]
- validate_all() delegates to validate_all_detailed() (backward compat)

Three operating modes:
- Mode A: latest git commit → git commit --amend
- Mode B: pre-commit hook file → write fixed message back to file
- Mode C: piped stdin → error (amending piped input is not supported)

Tests: 139 new tests across fixer_test.py, engine_test.py, main_test.py
- validate_all_detailed(silent=True) redirects stdout/stderr so the
  ASCII art banner does not appear before the fix proposal
- Clean up import ordering in main.py (subprocess with other stdlib)
- Add tests: silent output suppression, Mode B file read/write errors
@netlify
Copy link

netlify bot commented Mar 22, 2026

Deploy Preview for commit-check ready!

Name Link
🔨 Latest commit 1fbf343
🔍 Latest deploy log https://app.netlify.com/projects/commit-check/deploys/69c02bf484328800089a3bb8
😎 Deploy Preview https://deploy-preview-385--commit-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 22, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1f1ff017-902d-4d52-9d7b-9e99ea656252

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/add-ai-fix-commit

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use your project's `pylint` configuration to improve the quality of Python code reviews.

Add a pylint configuration file to your project to customize how CodeRabbit runs pylint.

@github-actions github-actions bot added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Mar 22, 2026
@sonarqubecloud
Copy link

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 22, 2026

Merging this PR will not alter performance

✅ 170 untouched benchmarks
🆕 29 new benchmarks
⏩ 108 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 test_check_result_frozen N/A 154 µs N/A
🆕 test_check_result_fields N/A 111.5 µs N/A
🆕 test_check_result_fail N/A 111.2 µs N/A
🆕 test_multiple_checks_all_returned N/A 823 µs N/A
🆕 test_validate_all_delegates_to_detailed N/A 528.8 µs N/A
🆕 test_returns_list_of_check_results N/A 529.1 µs N/A
🆕 test_validate_all_pass_when_all_pass N/A 801.5 µs N/A
🆕 test_validate_all_detailed_not_silent_prints_output N/A 1.2 ms N/A
🆕 test_pass_check_present_in_results N/A 528 µs N/A
🆕 test_fail_check_present_in_results N/A 1.2 ms N/A
🆕 test_validate_all_fail_when_any_fail N/A 1.2 ms N/A
🆕 test_validate_all_detailed_silent_suppresses_output N/A 590.4 µs N/A
🆕 test_unknown_check_skipped N/A 127.7 µs N/A
🆕 test_fix_with_author_email_exits_1 N/A 1.5 ms N/A
🆕 test_fixable_amends_and_exits_0 N/A 6.9 ms N/A
🆕 test_file_fixed_and_written_back N/A 4.4 ms N/A
🆕 test_amend_failure_exits_1 N/A 6.6 ms N/A
🆕 test_fix_with_author_name_exits_1 N/A 1.5 ms N/A
🆕 test_yes_without_fix_exits_1 N/A 1.4 ms N/A
🆕 test_already_compliant_exits_0 N/A 5.9 ms N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing feature/add-ai-fix-commit (1fbf343) with main (e45d40c)

Open in CodSpeed

Footnotes

  1. 108 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.

@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

❌ Patch coverage is 97.64151% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.26%. Comparing base (e45d40c) to head (1fbf343).

Files with missing lines Patch % Lines
commit_check/main.py 94.28% 4 Missing ⚠️
commit_check/fixer.py 99.22% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #385      +/-   ##
==========================================
+ Coverage   94.67%   95.26%   +0.59%     
==========================================
  Files           9       10       +1     
  Lines         807     1014     +207     
==========================================
+ Hits          764      966     +202     
- Misses         43       48       +5     

☔ View full report in Codecov by Sentry.
📢 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.

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

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant