From ac989e2c4db1fcc0963984d10fe3ecf3d6a3d4b5 Mon Sep 17 00:00:00 2001 From: Ozan Bozkurt Date: Fri, 6 Nov 2026 19:41:30 +0000 Subject: [PATCH] =?UTF-8?q?fix(checkout):=20support=20SHA=20refs=20?= =?UTF-8?q?=E2=80=94=20git=20clone=20--branch=20rejects=20them?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A SHA in `ref` died with "Remote branch not found" (killed the 2026-11-06 sim publish of SHA f0e206ff3: dispatch ref=branch + inputs.ref= is the publish-day pattern, since the Gitea dispatch API only accepts branch names). SHA-shaped refs now init+fetch the sha explicitly (the server allows anySHA fetch); branch/tag refs keep the exact old path. Sparse path already fetched this way. Co-Authored-By: Ozan Bozkurt Co-Authored-By: ZCode --- checkout/action.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/checkout/action.yml b/checkout/action.yml index dacd56c..842630f 100644 --- a/checkout/action.yml +++ b/checkout/action.yml @@ -12,7 +12,7 @@ inputs: description: 'Repository (owner/repo)' default: '${{ github.repository }}' ref: - description: 'Branch or tag to checkout' + description: 'Branch, tag or commit SHA to checkout' default: '${{ github.ref_name }}' depth: description: 'Clone depth (0 = full)' @@ -66,8 +66,16 @@ runs: git checkout FETCH_HEAD echo "Sparse checkout ${REPO}@${REF} ($(echo $SPARSE | wc -w) paths)" else - # Full clone - if [ "$TARGET" = "." ]; then + # Full clone. A SHA ref can't go through `clone --branch` (git: "Remote branch + # not found" — killed the 2026-11-06 sim publish of SHA f0e206ff3), so fetch + # it explicitly; the server allows anySHA fetch. Branch/tag refs keep the old path. + if echo "$REF" | grep -qE '^[0-9a-fA-F]{7,40}$'; then + mkdir -p "$TARGET" && cd "$TARGET" + git init + git remote add origin "$URL" + git fetch $DEPTH_FLAG origin "$REF" + git checkout FETCH_HEAD + elif [ "$TARGET" = "." ]; then git clone $DEPTH_FLAG --branch "$REF" "$URL" . else git clone $DEPTH_FLAG --branch "$REF" "$URL" "$TARGET"