From 1e0a70dc70954344e3bb5391a557dd48c78a1b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Huss?= Date: Tue, 23 Apr 2024 12:48:06 +0200 Subject: [PATCH] fix --- share/gitea-tekton-org/index.rhai | 1 - .../tekton.dev_v1beta1_Task_git-clone.yaml | 44 +++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/share/gitea-tekton-org/index.rhai b/share/gitea-tekton-org/index.rhai index 504e022..22febfa 100644 --- a/share/gitea-tekton-org/index.rhai +++ b/share/gitea-tekton-org/index.rhai @@ -10,7 +10,6 @@ const sources=[ #{url: "https://github.com/tektoncd/catalog/raw/main/task/check-make/0.1/check-make.yaml", name: "check-make.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/docker-build/0.1/docker-build.yaml", name: "docker-build.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/generate-build-id/0.1/generate-build-id.yaml", name: "generate-build-id.yaml"}, - #{url: "https://github.com/tektoncd/catalog/raw/main/task/git-clone/0.9/git-clone.yaml", name: "git-clone.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/gitea-set-status/0.1/gitea-set-status.yaml", name: "gitea-set-status.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/hadolint/0.1/hadolint.yaml", name: "hadolint.yaml"}, #{url: "https://github.com/tektoncd/catalog/raw/main/task/hugo/0.1/hugo.yaml", name: "hugo.yaml"}, diff --git a/share/gitea-tekton-org/tekton.dev_v1beta1_Task_git-clone.yaml b/share/gitea-tekton-org/tekton.dev_v1beta1_Task_git-clone.yaml index 050b135..433a1fc 100644 --- a/share/gitea-tekton-org/tekton.dev_v1beta1_Task_git-clone.yaml +++ b/share/gitea-tekton-org/tekton.dev_v1beta1_Task_git-clone.yaml @@ -45,6 +45,10 @@ spec: A workspace containing CA certificates, this will be used by Git to verify the peer with when fetching or pushing over HTTPS. params: + - name: toolbox-image + default: sebt3/basic-toolbox-image:1.30.0 + description: The name of the toolbox image + type: string - name: url description: Repository URL to clone from. type: string @@ -99,10 +103,6 @@ spec: description: Log the commands that are executed during `git-clone`'s operation. type: string default: "true" - - name: gitInitImage - description: The image providing the git-init binary that this Task runs. - type: string - default: "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.40.2" - name: userHome description: | Absolute path to the user's home directory. @@ -117,7 +117,7 @@ spec: description: The epoch timestamp of the commit that was fetched by this Task. steps: - name: clone - image: "$(params.gitInitImage)" + image: $(params.toolbox-image) env: - name: HOME value: "$(params.userHome)" @@ -220,16 +220,32 @@ spec: test -z "${PARAM_HTTPS_PROXY}" || export HTTPS_PROXY="${PARAM_HTTPS_PROXY}" test -z "${PARAM_NO_PROXY}" || export NO_PROXY="${PARAM_NO_PROXY}" + FETCH_CMD="" + if [ $PARAM_DEPTH -gt 0 ];then + FETCH_CMD+="--depth $PARAM_DEPTH" + fi git config --global --add safe.directory "${WORKSPACE_OUTPUT_PATH}" - /ko-app/git-init \ - -url="${PARAM_URL}" \ - -revision="${PARAM_REVISION}" \ - -refspec="${PARAM_REFSPEC}" \ - -path="${CHECKOUT_DIR}" \ - -sslVerify="${PARAM_SSL_VERIFY}" \ - -submodules="${PARAM_SUBMODULES}" \ - -depth="${PARAM_DEPTH}" \ - -sparseCheckoutDirectories="${PARAM_SPARSE_CHECKOUT_DIRECTORIES}" + git config --global --add http.sslVerify "${PARAM_SSL_VERIFY}" + cd "${CHECKOUT_DIR}" + git init + if [ "${PARAM_SPARSE_CHECKOUT_DIRECTORIES}" != "" ];then + git config --global --add core.sparsecheckout true + mkdir -p .git/info/ + echo "${PARAM_SPARSE_CHECKOUT_DIRECTORIES}"|sed 's/,/\n/'>.git/info/sparse-checkout + chmod 644 .git/info/sparse-checkout + fi + git remote add origin "${PARAM_URL}" + git fetch "--recurse-submodules=${PARAM_SUBMODULES}" $FETCH_CMD origin --update-head-ok --force + git reset --hard "${PARAM_REVISION}" + #/ko-app/git-init \ + # -url="${PARAM_URL}" \ + # -revision="${PARAM_REVISION}" \ + # -refspec="${PARAM_REFSPEC}" \ + # -path="${CHECKOUT_DIR}" \ + # -sslVerify="${PARAM_SSL_VERIFY}" \ + # -submodules="${PARAM_SUBMODULES}" \ + # -depth="${PARAM_DEPTH}" \ + # -sparseCheckoutDirectories="${PARAM_SPARSE_CHECKOUT_DIRECTORIES}" cd "${CHECKOUT_DIR}" RESULT_SHA="$(git rev-parse HEAD)" EXIT_CODE="$?"