Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
drone-git/posix/clone-commit
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
41 lines (35 sloc)
1017 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| FLAGS="" | |
| if [[ ! -z "${PLUGIN_DEPTH}" ]]; then | |
| FLAGS="--depth=${PLUGIN_DEPTH}" | |
| fi | |
| if [ ! -d .git ]; then | |
| git init | |
| git remote add origin ${DRONE_REMOTE_URL} | |
| fi | |
| # the branch may be empty for certain event types, | |
| # such as github deployment events. If the branch | |
| # 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 | |
| set -e | |
| set -x | |
| git fetch origin | |
| git checkout -qf ${DRONE_COMMIT_SHA} | |
| 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. | |
| 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} origin/${DRONE_COMMIT_BRANCH} | |
| exit 0 | |
| fi | |
| set -e | |
| set -x | |
| git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}: | |
| git checkout ${DRONE_COMMIT_SHA} -b ${DRONE_COMMIT_BRANCH} |