Skip to content

feat: name the commit in each finding, print the fix, add warn status - #278

Merged
shenxianpeng merged 1 commit into
mainfrom
claude/submit-patch-commit-check-42ac3i
Sep 6, 2026
Merged

feat: name the commit in each finding, print the fix, add warn status#278
shenxianpeng merged 1 commit into
mainfrom
claude/submit-patch-commit-check-42ac3i

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Sep 6, 2026

Copy link
Copy Markdown
Member

What

Four changes to what the Action shows and outputs. "Before" lines are from real runs of main.py on main under a faked pull_request event; "after" lines are the same runs on this branch (CLI 2.17.0, commits wip stuff, feat: add login page, fix: Handle timeout).

Each finding names its commit, with a link

git log now emits %H%x00%B%x00, so every message scope carries its commit's hash. The label stays Commit 2/3 in the result output (downstream matching keeps working) and a new sha field carries the full hash; where a person reads it the short hash is appended, and the summary table's Scope cell links to the commit (GITHUB_SERVER_URL is honoured, so it is right on GitHub Enterprise Server too; no GITHUB_REPOSITORY, no link). The tree cannot carry a link because it is a fenced code block. The non-PR Commit message scope carries git rev-parse HEAD.

| [Commit 2/3 (5584f46)](https://github.com/acme/widgets/commit/5584f46…) | `feat: add login page` | [CC002 subject-capitalized](…#cc002) |
  ✖ Commit 2/3 (5584f46) (1 failure)
      CC002 subject-capitalized
        value: feat: add login page
        Subject must start with a capital letter
        Fix: feat: Add login page
  ✔ Commit 3/3 (37d6def) (fix: Handle timeout)

Fix: in the tree and in the annotations

The CLI has returned fix (the corrected text) since 2.17 and the Action already forwarded it in result, but nothing rendered it. A new _finding_lines helper is the single source of the value: / Suggest: / Fix: rows for both the tree and the annotation payload, so the two cannot drift. When the CLI's suggest is exactly Use "<fix>", only Fix: is printed; bespoke suggestions (CC010, CC201) still print both. A multi-line fix (CC012 sign-off) takes one row per line.

Annotations, before and after:

::error title=CC002 subject-capitalized::Commit 2/3: Subject must start with a capital letter
::error title=CC002 subject-capitalized::Commit 2/3 (5584f46): Subject must start with a capital letter%0Avalue: feat: add login page%0AFix: feat: Add login page

GitHub renders %0A as line breaks, so the annotation on the Files changed tab is enough to act on without opening the step log.

result.status gains warn

overall_status reduces fail > all-skip > warn > pass. A run whose only findings are warned rules now reports status: warn instead of pass; the exit code is unchanged (exit_code_for still only fails on fail). Downstream:

- if: fromJSON(steps.commit-check.outputs.result).status == 'warn'
  run: echo "passed with warnings"

No more untitled ::error:: annotation

log_error_and_exit printed ::error::commit-check found 2 failures. after the per-finding annotations, so GitHub counted one error more than there were findings. It is replaced by a plain verdict line in the same voice as the passing and dry-run ones, ✖ commit-check: 2 of 5 checks failed (plus , 1 warning when applicable), computed by the same _check_counts as the Markdown verdict so the surfaces agree. Under dry-run the output is unchanged.

Docs: the spec comment block in main.py, README (result section now lists the four statuses and the fix/sha fields, examples show the SHA, link, Fix: and annotation shape) and action.yml's output description.

Compatibility

  • result.scopes[].label unchanged; sha and fix are additive.
  • result.status has one new value, warn, only for runs that previously reported pass while carrying warnings. Consumers checking == 'fail' are unaffected.
  • Exit codes unchanged.

Testing

  • 185 tests pass (160 before). Updated the tests that pinned the old annotation, parser return type, log_error_and_exit signature and overall_status; new tests cover the (sha, message) parser incl. blank-message alignment, head_sha success/128/OSError, display_label, the linked table with and without GITHUB_REPOSITORY, GHES server URL, non-commit scopes never linked, Fix/Suggest dedupe, bespoke suggest + fix, multi-line CC012 fix in tree and %0A annotation, the verdict line (exactly one ::error per finding, no untitled one), verdict with warnings, dry-run without , warn overall status with exit 0 and in GITHUB_OUTPUT, sha/fix in result.
  • 100% of changed lines covered (main.py 95% overall; the uncovered lines are pre-existing API/exception paths).
  • pre-commit run --all-files clean (black, mypy, codespell, …).
  • End-to-end self-test with a faked pull_request event against a scratch repo: failure, warn-only, dry-run and non-PR push runs; annotations, step summary and GITHUB_OUTPUT match the excerpts above (3 ::error annotations for 3 findings, result.status: warn on the warn-only run).

🤖 Generated with Claude Code

https://claude.ai/code/session_018xYa7m3qup5wyN5MaXFgf6


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Results now include statuses for pass, warn, skip, and fail, with clearer exit-code behavior.
    • Reports identify commit scopes with short hashes and linked commit details.
    • Findings can include suggested fixes and detailed failure annotations.
    • Warning-only results are reported explicitly without a failing exit code.
    • Result data now includes scope labels, commit SHAs, checks, and fixes.
  • Documentation

    • Expanded output reference and examples, including corrected branch-fix and job-summary guidance.

Item 10 (SHA and Fix). The tree and the tables said "Commit 2/3" with no
way to tell which commit that was; a reviewer had to count commits on
the PR. `git log` now runs with `%H%x00%B%x00`, `parse_commit_messages`
returns `(sha, message)` pairs, and `ScopeResult` gains `sha`. The
`label` stays "Commit 2/3" so the `result` output is stable for
downstream steps; the hash is appended where a person reads it
(`display_label`: "Commit 2/3 (5584f46)") and the summary table's Scope
cell links to the commit on `GITHUB_SERVER_URL`/`GITHUB_REPOSITORY`.
The non-PR "Commit message" scope carries `git rev-parse HEAD`. The CLI
has shipped `fix` (the corrected text) since 2.15 and the action already
forwarded it in `result`, but never rendered it; the tree now prints
`Fix:` after `Suggest:`, one row per line for a multi-line fix (CC012
sign-off). When the CLI's `suggest` is just `Use "<fix>"` only `Fix:` is
printed, so the same text is not shown twice in a row.

Item 9 (annotation detail). The `::error` annotation carried only the
scope label and the error's first line, so on the Files changed tab the
reader saw "Subject must start with a capital letter" and nothing to act
on. The value, suggestion and fix are now appended as `%0A`-separated
lines, produced by the same `_finding_lines` helper the tree uses, so
the two surfaces cannot drift.

Item 11 (`warn` status). `overall_status` collapsed a warn-only run into
"pass", although every human surface already said "1 warning". It now
returns "warn" (fail > all-skip > warn > pass); `exit_code_for` is
unchanged, so only "fail" is ever non-zero. README lists the four values
and adds the missing `fix` field.

Item 12 (untitled annotation). `log_error_and_exit` printed
`::error::commit-check found N failures.` after the per-finding
annotations, so GitHub counted one error more than there were findings
and listed an untitled entry that only restated the titled ones. The
failure verdict is now a plain `✖ commit-check: 2 of 5 checks failed`
line next to the existing `✔`/dry-run verdicts, counted by
`_check_counts` so the step log, summary and comment agree.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018xYa7m3qup5wyN5MaXFgf6
@shenxianpeng
shenxianpeng requested a review from a team as a code owner September 6, 2026 23:22
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: c4b3a996-eeb5-4949-b1cd-2812853fdc83

📥 Commits

Reviewing files that changed from the base of the PR and between 7ae61d9 and 1188267.

📒 Files selected for processing (4)
  • README.md
  • action.yml
  • main.py
  • main_test.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The action now preserves commit SHAs through validation, displays short hashes and commit links, renders detailed findings and fixes, distinguishes warning results, and serializes expanded scope data. Documentation and tests cover the updated output and status behavior.

Changes

Commit-aware results and reporting

Layer / File(s) Summary
Commit identity propagation
main.py, main_test.py
Git readers return SHA/message pairs. ScopeResult stores full SHAs and exposes short-hash display labels. Tests cover PR refs, HEAD resolution, empty messages, and shallow fallbacks.
Finding and report rendering
main.py, main_test.py, README.md
Findings now render values, suggestions, fixes, and per-finding annotations. Reports display short hashes and optional commit links. Tests cover multiline fixes, server URLs, and updated examples.
Status and structured output
main.py, action.yml, main_test.py, README.md
Warning status takes precedence over skips when no failure exists. Structured results include scope SHAs. Exit handling omits the redundant summary annotation. Documentation describes the updated statuses and output fields.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 11882

Commit-aware reporting, warning statuses, fixes, annotations, and structured outputs are consistently implemented and documented, with no identified merge-blocking impact.

Sequence Diagram(s)

sequenceDiagram
  participant Git
  participant CommitChecks
  participant ScopeResult
  participant Reporter
  participant ActionOutput
  Git->>CommitChecks: Read commit SHA and message
  CommitChecks->>ScopeResult: Store checks and SHA
  ScopeResult->>Reporter: Render findings and commit label
  Reporter->>ActionOutput: Emit annotations, report, and result JSON
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 91 functions across 2 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: associating findings with commits, displaying fixes, and adding warn status.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 91 functions across 2 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/submit-patch-commit-check-42ac3i

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.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Commit Check

All 5 checks passed

Show all 5 checks
Commit message
  ✔ PR title (feat: name the commit in each finding, print the fix, add...)
  ✔ Commit 1/1 (1188267) (feat: name the commit in each finding, print the fix, add...)
Branch
  ✔ Branch (claude/submit-patch-commit-check-42ac3i)
Author
  ✔ Author name (Xianpeng Shen)
  ✔ Author email (xianpeng.shen@gmail.com)

commit-check 2.17.0 · Rules reference

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.86%. Comparing base (7ae61d9) to head (1188267).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #278      +/-   ##
==========================================
+ Coverage   94.48%   94.86%   +0.37%     
==========================================
  Files           1        1              
  Lines         544      584      +40     
==========================================
+ Hits          514      554      +40     
  Misses         30       30              
Flag Coverage Δ
unittests 94.86% <100.00%> (+0.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@shenxianpeng
shenxianpeng merged commit 046b66d into main Sep 6, 2026
22 checks passed
@shenxianpeng
shenxianpeng deleted the claude/submit-patch-commit-check-42ac3i branch September 6, 2026 23:49
@shenxianpeng shenxianpeng added the enhancement New feature or request label Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant