fix(checkout): support SHA refs — git clone --branch rejects them
A SHA in `ref` died with "Remote branch <sha> not found" (killed the 2026-11-06 sim publish of SHA f0e206ff3: dispatch ref=branch + inputs.ref=<sha> 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 <ozan@tinqs.com> Co-Authored-By: ZCode <GLM-5.3 via ZCode>
This commit is contained in:
1 parent
9dbf071934
commit
56156b5ea6
1 file changed
+11
-3
+11
-3
@@ -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
|
||||
# <sha> 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"
|
||||
|
||||
Reference in new issue
Block a user