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)'
|
description: 'Repository (owner/repo)'
|
||||||
default: '${{ github.repository }}'
|
default: '${{ github.repository }}'
|
||||||
ref:
|
ref:
|
||||||
description: 'Branch or tag to checkout'
|
description: 'Branch, tag or commit SHA to checkout'
|
||||||
default: '${{ github.ref_name }}'
|
default: '${{ github.ref_name }}'
|
||||||
depth:
|
depth:
|
||||||
description: 'Clone depth (0 = full)'
|
description: 'Clone depth (0 = full)'
|
||||||
@@ -66,8 +66,16 @@ runs:
|
|||||||
git checkout FETCH_HEAD
|
git checkout FETCH_HEAD
|
||||||
echo "Sparse checkout ${REPO}@${REF} ($(echo $SPARSE | wc -w) paths)"
|
echo "Sparse checkout ${REPO}@${REF} ($(echo $SPARSE | wc -w) paths)"
|
||||||
else
|
else
|
||||||
# Full clone
|
# Full clone. A SHA ref can't go through `clone --branch` (git: "Remote branch
|
||||||
if [ "$TARGET" = "." ]; then
|
# <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" .
|
git clone $DEPTH_FLAG --branch "$REF" "$URL" .
|
||||||
else
|
else
|
||||||
git clone $DEPTH_FLAG --branch "$REF" "$URL" "$TARGET"
|
git clone $DEPTH_FLAG --branch "$REF" "$URL" "$TARGET"
|
||||||
|
|||||||
Reference in new issue
Block a user