From fc019e513c12a677513392a341e779af2a0bf630 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 29 Oct 2020 10:18:31 -0400 Subject: [PATCH] fix checkout by branch --- posix/clone-commit | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/posix/clone-commit b/posix/clone-commit index 00405e4..023ed70 100755 --- a/posix/clone-commit +++ b/posix/clone-commit @@ -23,11 +23,16 @@ if [[ -z "${DRONE_COMMIT_BRANCH}" ]]; then exit 0 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. Note that +# we intentially omit depth flags to avoid failed +# clones due to lack of history. if [[ -z "${DRONE_COMMIT_SHA}" ]]; then set -e set -x - git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}: - git checkout -b ${DRONE_COMMIT_BRANCH} + git fetch origin +refs/heads/${DRONE_COMMIT_BRANCH}: + git checkout -b ${DRONE_COMMIT_BRANCH} origin/${DRONE_COMMIT_BRANCH} exit 0 fi