Skip to content

Fix: rebase before squashing in fix-pr, and check the diff with three dots - #1516

Merged
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/fix-pr-rebase-before-squash
Jul 27, 2026
Merged

Fix: rebase before squashing in fix-pr, and check the diff with three dots#1516
ChaoWao merged 1 commit into
hw-native-sys:mainfrom
ChaoWao:fix/fix-pr-rebase-before-squash

Conversation

@ChaoWao

@ChaoWao ChaoWao commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

What

fix-pr Step 6 told you to squash first and rebase after; commit-and-push has
the opposite (correct) order. The two documents disagreed, and the skill's order
is the one that corrupts the commit. Step 6 now fetches and rebases before it
stages anything, and verification uses a three-dot diff.

Why it matters

git reset --soft "$BASE_REF" moves HEAD to the base but keeps the branch's
index. If the branch still sits on an older base — which it does whenever
anything merged while the PR was open — every file the base gained meanwhile is
recorded as a deletion by the PR
. Rebasing afterwards does not repair it: the
revert is by then part of the PR's own diff and replays cleanly onto the new base.

Hit for real while squashing #1506: docs/troubleshooting/device-error-codes.md
came back as −86 lines, because #1501 had merged since the branch point. Caught
by eye during a file-list review; nothing in the workflow would have flagged it.

Also

Verification now uses git diff "$BASE_REF"...HEAD --stat (three dots). Two dots
also lists files the base has and the branch does not, rendering them as the
branch's deletions — so it simultaneously hides a real revert in the noise and
invents fake ones. I chased two phantom "deletions" that way in the same session
before realising the diff form was wrong.

commit-and-push §1 gains the git fetch ($BASE_REF is a remote-tracking ref
and goes stale in a long session), and its soft-reset step now states the
precondition it silently relied on.

Docs only — no code paths touched.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f003b657-f45b-4234-84dd-6615b7630231

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
📝 Walkthrough

Walkthrough

The documentation now requires refreshing and rebasing onto $BASE_REF before squashing or folding commits. It also adds post-fold checks for a single commit ahead and unintended three-dot diffs.

Changes

Git workflow documentation

Layer / File(s) Summary
Rebase preparation and ordering
.claude/lib/github/commit-and-push.md, .claude/skills/fix-pr/SKILL.md
The instructions refresh $BASE_REF and require rebasing before squashing or folding commits.
Squash safety and verification
.claude/lib/github/commit-and-push.md, .claude/skills/fix-pr/SKILL.md
The guides document stale-base deletion risks and require single-commit and three-dot diff verification before pushing.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A bunny rebases, neat and bright,
Then folds each commit just right.
Fresh bases guide the way,
Diff checks guard the day,
No stray files hop out of sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main docs change: rebasing before squashing and using a three-dot diff.
Description check ✅ Passed The description is clearly related to the workflow documentation changes and matches the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/lib/github/commit-and-push.md:
- Around line 73-79: The verification command is positioned incorrectly after
git reset --soft "$BASE_REF", where the three-dot diff is empty regardless of
staged deletions. Move the git diff "$BASE_REF"...HEAD --stat check to
immediately after the squashed commit is created, or use git diff --cached
"$BASE_REF" --stat at the current staged state, while preserving the warning and
push guidance.

In @.claude/skills/fix-pr/SKILL.md:
- Around line 244-246: Update the verification instructions around COMMITS_AHEAD
so zero commits terminates the workflow as an error, while only values greater
than one require squashing before pushing. Preserve the requirement that exactly
one commit must be present for a valid push.
- Around line 218-226: Update the rebase sequence in the fix workflow so edits
made in the preceding step are preserved before running git rebase "$BASE_REF".
Either move this rebase earlier than the edit step or stash tracked and
untracked changes, fetch and rebase, then restore the stash before git add -A;
keep the existing commit-count calculation after restoration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d3cf6b19-17eb-4b44-80a0-fe7145ca154e

📥 Commits

Reviewing files that changed from the base of the PR and between 2d0fbf4 and 748f49d.

📒 Files selected for processing (2)
  • .claude/lib/github/commit-and-push.md
  • .claude/skills/fix-pr/SKILL.md

Comment thread .claude/lib/github/commit-and-push.md
Comment thread .claude/skills/fix-pr/SKILL.md Outdated
Comment thread .claude/skills/fix-pr/SKILL.md Outdated
@ChaoWao
ChaoWao force-pushed the fix/fix-pr-rebase-before-squash branch from 748f49d to cbeb06f Compare July 27, 2026 03:45
… dots

`fix-pr` Step 6 told you to squash first and rebase after: the `> 1` row
soft-resets to `$BASE_REF`, and only the following list says "rebase onto
`$BASE_REF`". `commit-and-push` has the opposite (correct) order, so the two
documents disagreed and the skill's order is the one that corrupts the commit.

`git reset --soft "$BASE_REF"` moves HEAD to the base but keeps the branch's
index. If the branch still sits on an older base — which it does whenever
anything merged while the PR was open — every file the base gained meanwhile is
recorded as a deletion by the PR. Rebasing afterwards does not repair it: the
revert is by then part of the PR's own diff and replays cleanly onto the new
base. It surfaces as unrelated files being reverted, easy to miss in a large
diff and easy to merge.

Hit while squashing hw-native-sys#1506: `docs/troubleshooting/device-error-codes.md` came
back as -86 lines because hw-native-sys#1501 had merged since the branch point.

Step 6 now fetches and rebases at the top, *before* the edit step rather than
after it: git refuses to rebase a dirty worktree, so a rebase placed after the
fix cannot run at all. Verification gains a three-dot diff of the file list, and
it lives with the single-commit check after the commit exists — at the
soft-reset itself `HEAD` is `$BASE_REF`, so that diff is empty by construction
and would have verified nothing. Two dots would also list files the base has and
the branch does not, rendering them as the branch's deletions: it both hides a
real revert in the noise and invents fake ones.

The single-commit check now separates its outcomes, since the surrounding table
already treats them differently: `> 1` squashes again, `0` stops.

`commit-and-push` §1 gains the fetch, and its soft-reset step states the
precondition it silently relied on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ChaoWao

ChaoWao commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai All three addressed — thanks, two of them were bugs this very PR introduced:

  • commit-and-push §3 verification placement — correct, the three-dot diff was empty by construction right after git reset --soft. Moved to §5 where the commit exists; §3 now says why not to check there.
  • rebase on a dirty worktree — correct, and it reproduced immediately when I ran the workflow as written (error: Please commit or stash them). Fetch+rebase moved to the top of Step 6, ahead of the edit step, rather than stashing.
  • COMMITS_AHEAD=0 — correct, "if not 1, squash again" contradicted the table above it. Split into > 1 squash / 0 stop / 1 proceed.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@ChaoWao Thanks for addressing all three—and for validating the dirty-worktree failure directly. The revised ordering and explicit COMMITS_AHEAD branches resolve the workflow contradictions.

🐇 ✅


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

@ChaoWao
ChaoWao merged commit 2769416 into hw-native-sys:main Jul 27, 2026
13 of 14 checks passed
@ChaoWao
ChaoWao deleted the fix/fix-pr-rebase-before-squash branch July 27, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant