Skip to content

Commit fd17865

Browse files
committed
merge latest git-clone.sh
1 parent 79afb97 commit fd17865

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

.github/container/git-clone.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ while [ : ]; do
4848
;;
4949
--)
5050
shift;
51-
break
51+
break
5252
;;
5353
esac
5454
done
@@ -73,7 +73,7 @@ fi
7373

7474
## check out the source
7575
GIT_REPO=$(cut -d# -f1 <<< $GIT_URLREF)
76-
GIT_REF=$(cut -d# -f2- <<< $GIT_URLREF)
76+
GIT_REF=$(cut -s -d# -f2- <<< $GIT_URLREF)
7777

7878
echo "Fetching $GIT_REPO#$GIT_REF to $DESTINATION"
7979

@@ -86,17 +86,25 @@ if [[ -n "${SPARSE_PATH}" ]]; then
8686
git sparse-checkout set ${SPARSE_PATH}
8787
popd
8888
else
89-
git clone ${GIT_REPO} ${DESTINATION}
89+
git clone ${GIT_REPO} ${DESTINATION}
9090
fi
9191
pushd ${DESTINATION}
92-
git checkout ${GIT_REF}
92+
if [[ -n "${GIT_REF}" ]]; then
93+
git checkout ${GIT_REF}
94+
fi
9395
COMMIT_SHA=$(git rev-parse HEAD)
9496
git submodule update --init --recursive
97+
if [[ "${GIT_REPO}" == *"gitlab"* ]]; then
98+
git remote remove origin
99+
if grep -q -r gitlab-ci-token .git; then
100+
grep -r gitlab-ci-token .git | awk -F: '{print $1}' | xargs rm -f
101+
fi
102+
git branch -D main
103+
fi
95104
popd
96105

97106
## update the manifest file
98-
99107
mkdir -p $(dirname ${MANIFEST})
100108
touch ${MANIFEST}
101109
PACKAGE=$(basename "${DESTINATION}")
102-
yq eval --inplace ". += {\"${PACKAGE}\": {\"url\": \"${GIT_REPO}\", \"tracking_ref\": \"${GIT_REF}\", \"latest_verified_commit\": \"${COMMIT_SHA}\", \"mode\": \"git-clone\"}}" ${MANIFEST}
110+
yq eval --inplace ". += {\"${PACKAGE}\": {\"url\": \"${GIT_REPO}\", \"tracking_ref\": \"${GIT_REF}\", \"latest_verified_commit\": \"${COMMIT_SHA}\", \"mode\": \"git-clone\"}}" ${MANIFEST}

0 commit comments

Comments
 (0)