This repository has been archived by the owner before Nov 9, 2022. It is now read-only.
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-pull-request
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
43 lines (34 sloc)
1.01 KB
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 | |
| # pull request ref | |
| REF="pull/${DRONE_PULL_REQUEST}/head" | |
| # pull request ref, bitbucket | |
| # case being used because pattern matching in /bin/sh needs to use case. | |
| case "$DRONE_REMOTE_URL" in | |
| "https://bitbucket.org/"*) REF="refs/pull-requests/${DRONE_PULL_REQUEST}/from" ;; | |
| *) ;; | |
| esac | |
| # pull request ref, gitlab | |
| # case being used because pattern matching in /bin/sh needs to use case. | |
| case "$DRONE_COMMIT_REF" in | |
| "refs/merge-requests/"*) REF="refs/merge-requests/${DRONE_PULL_REQUEST}/head" ;; | |
| *) ;; | |
| esac | |
| 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 | |
| set -e | |
| set -x | |
| git fetch ${FLAGS} origin +refs/heads/${DRONE_BRANCH}: | |
| git checkout ${DRONE_BRANCH} | |
| git fetch origin ${REF}: | |
| git rebase ${DRONE_COMMIT} | |
| # git clone ${FLAGS} -b ${DRONE_BRANCH} --single-branch ${DRONE_REMOTE_URL} \ | |
| # ${DRONE_WORKSPACE} | |
| # | |
| # git fetch origin pull/${DRONE_PULL_REQUEST}/head: | |
| # git rebase ${DRONE_COMMIT} |