git-docker/rootfs/usr/local/bin/clone-pull-request

20 lines
363 B
Plaintext
Raw Normal View History

2023-10-01 16:54:37 +00:00
#!/bin/bash
2023-10-01 19:16:54 +00:00
set -e
2023-10-01 16:54:37 +00:00
FLAGS=""
if [[ -n "${PLUGIN_DEPTH}" ]]; then
2023-10-01 18:44:02 +00:00
FLAGS="--depth=${PLUGIN_DEPTH}"
2023-10-01 16:54:37 +00:00
fi
if [ ! -d .git ]; then
2023-10-01 18:44:02 +00:00
git init
git remote add origin "${DRONE_REMOTE_URL}"
2023-10-01 16:54:37 +00:00
fi
2023-10-01 18:44:02 +00:00
git fetch ${FLAGS} origin "+refs/heads/${DRONE_COMMIT_BRANCH}:"
2023-10-01 16:54:37 +00:00
git checkout "${DRONE_COMMIT_BRANCH}"
git fetch origin "${DRONE_COMMIT_REF}:"
git merge "${DRONE_COMMIT_SHA}"