fix: git clone by refspec
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
parent
2ca1f86ec4
commit
db6bbad75b
@ -17,7 +17,7 @@ fi
|
||||
# is empty we checkout the sha directly. Note that
|
||||
# we intentially omit depth flags to avoid failed
|
||||
# clones due to lack of history.
|
||||
if [[ -z "${DRONE_COMMIT_BRANCH}" ]]; then
|
||||
if [[ -z "${DRONE_COMMIT_BRANCH}" ]] && [[ -n "${DRONE_COMMIT_SHA}" ]]; then
|
||||
set -e
|
||||
set -x
|
||||
git fetch origin
|
||||
@ -28,16 +28,18 @@ fi
|
||||
# the commit sha may be empty for builds that are
|
||||
# manually triggered in Harness CI Enterprise. If
|
||||
# the commit is empty we clone the branch.
|
||||
if [[ -z "${DRONE_COMMIT_SHA}" ]]; then
|
||||
if [[ -n "${DRONE_COMMIT_BRANCH}" ]] && [[ -z "${DRONE_COMMIT_SHA}" ]]; then
|
||||
set -e
|
||||
set -x
|
||||
git fetch "${FLAGS}" origin "+refs/heads/${DRONE_COMMIT_BRANCH}:"
|
||||
git checkout -b "${DRONE_COMMIT_BRANCH}" "origin/${DRONE_COMMIT_BRANCH}"
|
||||
git fetch "${FLAGS}" origin "+refs/heads/${DRONE_COMMIT_BRANCH}:refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
|
||||
git checkout -b "${DRONE_COMMIT_BRANCH}" "refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# if the commit sha and branch name not empty, fetch the branch even if a
|
||||
# fast-forward is not possible. Checkout the specified commit sha which must be
|
||||
# part of the branch.
|
||||
set -e
|
||||
set -x
|
||||
|
||||
git fetch "${FLAGS}" origin "+refs/heads/${DRONE_COMMIT_BRANCH}:"
|
||||
git checkout "${DRONE_COMMIT_SHA}" -b "${DRONE_COMMIT_BRANCH}"
|
||||
git fetch "${FLAGS}" origin "+refs/heads/${DRONE_COMMIT_BRANCH}:refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
|
||||
git checkout "${DRONE_COMMIT_SHA}" -b "refs/remotes/origin/${DRONE_COMMIT_BRANCH}"
|
||||
|
Loading…
Reference in New Issue
Block a user