Skip to content

fix(stack): keep squash --message temp file alive across rebase conflicts#1386

Merged
mergify[bot] merged 1 commit intomainfrom
devs/jd/fix/squash-msg-file-conflict/keep-squash-msg-temp-file-alive-across-rebase--a026b5b6
May 11, 2026
Merged

fix(stack): keep squash --message temp file alive across rebase conflicts#1386
mergify[bot] merged 1 commit intomainfrom
devs/jd/fix/squash-msg-file-conflict/keep-squash-msg-temp-file-alive-across-rebase--a026b5b6

Conversation

@jd
Copy link
Copy Markdown
Member

@jd jd commented May 7, 2026

stack_squash with -m writes the new commit message to a temp file
and inserts an exec git commit --amend -F <tmpfile> line in the
rebase todo. The previous code wrapped the rebase in try/finally so
the temp file was unlinked even when the rebase failed mid-way (e.g.
conflicts on a fixup line that runs before the exec). After the user
resolved conflicts and ran git rebase --continue, git would replay
the exec line and fail because the message file no longer existed.

Drop the finally; only unlink on the success path. If the rebase
raises SystemExit, the file persists so --continue can still execute
the amend. The temp file lives in /tmp and gets cleaned by the OS.

Same pattern (and same fix) as stack_reword — flagged by Copilot on

#1384 review.

Copilot AI review requested due to automatic review settings May 7, 2026 18:33
@mergify mergify Bot had a problem deploying to Mergify Merge Protections May 7, 2026 18:33 Failure
@jd jd temporarily deployed to func-tests-live May 7, 2026 18:33 — with GitHub Actions Inactive
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 7, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts stack_squash -m/--message to avoid deleting the temporary commit-message file when an interactive rebase stops mid-way (e.g., due to conflicts), so git rebase --continue can still replay the inserted exec git commit --amend -F <tmpfile> line successfully.

Changes:

  • Removes the try/finally cleanup around the temp message file in stack_squash.
  • Unlinks the temp message file only after a successful run_action_rebase completion.
  • Adds inline rationale explaining why the file must persist across conflict-driven rebase interruptions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread mergify_cli/stack/squash.py Outdated
Comment thread mergify_cli/stack/squash.py
@mergify mergify Bot requested a review from a team May 7, 2026 18:47
@jd jd marked this pull request as ready for review May 8, 2026 13:10
…icts

`stack_squash` with `-m` writes the new commit message to a temp file
and inserts an `exec git commit --amend -F <tmpfile>` line in the
rebase todo. The previous code wrapped the rebase in `try/finally` so
the temp file was unlinked even when the rebase failed mid-way (e.g.
conflicts on a fixup line that runs before the exec). After the user
resolved conflicts and ran `git rebase --continue`, git would replay
the exec line and fail because the message file no longer existed.

Drop the `finally`; only unlink on the success path. If the rebase
raises SystemExit, the file persists so `--continue` can still execute
the amend. The temp file lives in `/tmp` and gets cleaned by the OS.

Same pattern (and same fix) as `stack_reword` — flagged by Copilot on

Change-Id: Ia026b5b631ed043a03983beec5ca81fd29f77633
#1384 review.
@jd jd force-pushed the devs/jd/fix/squash-msg-file-conflict/keep-squash-msg-temp-file-alive-across-rebase--a026b5b6 branch from a87e24c to ab5c073 Compare May 8, 2026 13:16
@jd
Copy link
Copy Markdown
Member Author

jd commented May 8, 2026

Revision history

# Type Changes Reason Date
1 initial a87e24c 2026-05-08 13:16 UTC
2 content a87e24c → ab5c073 (raw) address copilot review: reword the /tmp comment to system temp directory; add test that monkeypatches run_action_rebase to raise SystemExit and asserts the message file persists for git rebase --cont… 2026-05-08 13:16 UTC

@jd jd temporarily deployed to func-tests-live May 8, 2026 13:16 — with GitHub Actions Inactive
@mergify mergify Bot deployed to Mergify Merge Protections May 8, 2026 13:17 Active
@mergify mergify Bot requested a review from a team May 11, 2026 08:26
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 11, 2026

Merge Queue Status

This pull request spent 14 minutes 45 seconds in the queue, including 14 minutes 23 seconds running CI.

Required conditions to merge

mergify Bot added a commit that referenced this pull request May 11, 2026
@mergify mergify Bot added the queued label May 11, 2026
mergify Bot added a commit that referenced this pull request May 11, 2026
@mergify mergify Bot merged commit a1ea1dc into main May 11, 2026
19 checks passed
@mergify mergify Bot deleted the devs/jd/fix/squash-msg-file-conflict/keep-squash-msg-temp-file-alive-across-rebase--a026b5b6 branch May 11, 2026 08:49
@mergify mergify Bot removed the queued label May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants