fix(stack): anchor old PR head SHAs in local refs for revision history#1314
Closed
jd wants to merge 1 commit into
Conversation
`fetch_old_pr_heads` previously fetched `refs/pull/N/head` with no destination refspec, leaving the SHA reachable only via FETCH_HEAD — which any subsequent fetch (or background `gc`) can drop. When the SHA is no longer locally reachable, `git show <old_sha>` fails inside `_git_patch_id`, and `detect_change_type` falls back to the "unknown" classification in the PR's revision-history comment. Fetch into a stable per-PR ref under `refs/mergify/stack/old-pr-heads/<N>` (forced refspec, with `--no-write-fetch-head` to avoid touching the shared FETCH_HEAD pointer). The SHA is then anchored by a real ref for the lifetime of the patch-id comparison and beyond, so future runs can compare even after a long gap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Change-Id: Ie5aebff2f4cb939d7f5f448245da5b358361f6ef
Member
Author
|
This pull request is part of a Mergify stack:
|
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 👀 Review RequirementsWaiting for:
This rule is failing.
🔴 🔎 ReviewsWaiting for:
This rule is failing.
🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes revision-history change-type detection in stack push by ensuring “old PR head” SHAs remain locally reachable (not just via FETCH_HEAD) so patch-id comparisons don’t degrade to "unknown" after subsequent fetches or garbage collection.
Changes:
- Fetch
refs/pull/<N>/headinto stable local refs underrefs/mergify/stack/old-pr-heads/<N>using a forced refspec. - Add
--no-write-fetch-headto avoid mutating the sharedFETCH_HEAD. - Update stack push tests to assert the new
git fetchinvocation/refspecs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
mergify_cli/stack/push.py |
Implements anchored per-PR local refs for old head SHAs and avoids writing FETCH_HEAD. |
mergify_cli/tests/stack/test_push.py |
Updates mocks/assertions to match the new fetch refspec + flags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fetch_old_pr_headspreviously fetchedrefs/pull/N/headwith nodestination refspec, leaving the SHA reachable only via FETCH_HEAD —
which any subsequent fetch (or background
gc) can drop. When theSHA is no longer locally reachable,
git show <old_sha>fails inside_git_patch_id, anddetect_change_typefalls back to the"unknown" classification in the PR's revision-history comment.
Fetch into a stable per-PR ref under
refs/mergify/stack/old-pr-heads/<N>(forced refspec, with
--no-write-fetch-headto avoid touching theshared FETCH_HEAD pointer). The SHA is then anchored by a real ref
for the lifetime of the patch-id comparison and beyond, so future
runs can compare even after a long gap.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com