From 9e802978fbfd79e7bb73100a9715fd10dfdb6d7e Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Thu, 27 Aug 2026 03:38:41 -0500 Subject: [PATCH] .github: automerge: unshallow repo before merge-base 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. --- .github/scripts/automerge.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/scripts/automerge.py b/.github/scripts/automerge.py index d224ded73ca..3f57294ab31 100644 --- a/.github/scripts/automerge.py +++ b/.github/scripts/automerge.py @@ -454,6 +454,21 @@ def main() -> None: print(f"Fetching origin/{TARGET_BRANCH}…") run_net(["git", "fetch", "origin", TARGET_BRANCH], cwd=repo) + # Unshallow if needed so that merge-base can find the common ancestor + # between origin/TARGET_BRANCH and sourceware/UPSTREAM_BRANCH. + is_shallow = ( + run( + ["git", "rev-parse", "--is-shallow-repository"], + cwd=repo, + ).stdout.strip() + == "true" + ) + if is_shallow: + print(f"Repo is shallow; unshallowing origin/{TARGET_BRANCH}…") + run_net( + ["git", "fetch", "--unshallow", "origin", TARGET_BRANCH], cwd=repo + ) + # ------------------------------------------------------------------ # # 5. Determine the commit range to merge. # # ------------------------------------------------------------------ #