.github: automerge: unshallow repo before merge-base - #311
Merged
Conversation
When the workflow uses actions/checkout with the default fetch-depth of 1, the working repo is shallow. Fetching sourceware/master brings in full history, but git merge-base then fails with exit code 1 because the shallow origin/amd-staging tip has no common ancestor reachable in its truncated history. Detect a shallow repository after fetching origin/TARGET_BRANCH and immediately unshallow it so that the subsequent merge-base call can find the common ancestor. When the script manages its own clone the repo is never shallow, so this path is a no-op there.
Collaborator
Author
|
Self-approving as it is parallel to CI and a simple fix. |
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.
Problem
The automerge workflow uses
actions/checkoutwith the defaultfetch-depth: 1, producing a shallow clone. The script reuses thatrepo (
--repo $WORKSPACE), fetches fullsourceware/masterhistory,then calls:
This fails with exit code 1 because the shallow clone does not contain
the common ancestor. Example failure:
https://github.com/ROCm/ROCgdb/actions/runs/33000292878/job/98280035701
Fix
After fetching
origin/TARGET_BRANCH, check whether the repo is shallow(
git rev-parse --is-shallow-repository) and unshallow it if so. Whenthe script manages its own clone the repo is never shallow, so this is a
no-op on that path.