init
This commit is contained in:
parent
e7e998b1a7
commit
9cf2952c24
@ -9,11 +9,11 @@ spec:
|
|||||||
The commit SHA, committer date, and fetched URL are exposed as Task results.
|
The commit SHA, committer date, and fetched URL are exposed as Task results.
|
||||||
|
|
||||||
params:
|
params:
|
||||||
- name: repoUrl
|
- name: url
|
||||||
type: string
|
type: string
|
||||||
description: The Git repository URL to clone.
|
description: The Git repository URL to clone.
|
||||||
|
|
||||||
- name: revision
|
- name: ref
|
||||||
type: string
|
type: string
|
||||||
default: ""
|
default: ""
|
||||||
description: The branch or commit SHA to check out. If empty, default branch will be used.
|
description: The branch or commit SHA to check out. If empty, default branch will be used.
|
||||||
@ -169,16 +169,33 @@ spec:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[INFO] Cloning repository..."
|
echo "[INFO] Cloning repository..."
|
||||||
git clone --depth=$(params.depth) $(params.repoUrl) "$CLONE_DIR"
|
git clone --depth=$(params.depth) $(params.url) "$CLONE_DIR"
|
||||||
cd "$CLONE_DIR"
|
cd "$CLONE_DIR"
|
||||||
|
|
||||||
if [ -n "$(params.refspec)" ]; then
|
if [ -n "$(params.refspec)" ]; then
|
||||||
git fetch origin $(params.refspec)
|
git fetch origin $(params.refspec)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$(params.revision)" ]; then
|
REF="$(params.ref)"
|
||||||
echo "[INFO] Checking out revision: $(params.revision)"
|
if [ -n "$REF" ]; then
|
||||||
git checkout $(params.revision) || git checkout -b $(params.revision) origin/$(params.revision) || echo "[WARN] Failed to checkout revision"
|
if echo "$REF" | grep -q '^refs/heads/'; then
|
||||||
|
BRANCH="${REF#refs/heads/}"
|
||||||
|
echo "[INFO] Checking out branch: $BRANCH"
|
||||||
|
git checkout -b "$BRANCH" "origin/$BRANCH" || git checkout "$BRANCH"
|
||||||
|
elif echo "$REF" | grep -q '^refs/tags/'; then
|
||||||
|
TAG="${REF#refs/tags/}"
|
||||||
|
echo "[INFO] Checking out tag: $TAG"
|
||||||
|
git fetch --tags
|
||||||
|
git checkout "tags/$TAG" || git checkout "$TAG"
|
||||||
|
elif git rev-parse --verify "$REF" >/dev/null 2>&1; then
|
||||||
|
echo "[INFO] Checking out commit SHA: $REF"
|
||||||
|
git checkout "$REF"
|
||||||
|
else
|
||||||
|
echo "[ERROR] Invalid revision: $REF not found as branch, tag, or commit"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[INFO] No revision specified, staying on default branch"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$(params.submodules)" = "true" ]; then
|
if [ "$(params.submodules)" = "true" ]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user