From 7a6564cc28d1bbd07417f1d1afdfdc0bbd7bf715 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 14 Dec 2018 18:10:09 -0800 Subject: [PATCH] fix issue with missing author and email --- README.md | 24 ++++++++++++++++++++++++ posix/clone | 17 +++++++++++++---- posix/clone-pull-request | 2 +- 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..879119a --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# drone-git + +Drone plugin to clone `git` repositories. + +## Build + +Build the Docker image with the following commands: + +``` +docker build --rm -f docker/Dockerfile.linux.amd64 -t drone/git . +``` + +## Usage + +Clone a commit: + +``` +docker run --rm \ + -e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \ + -e DRONE_BUILD_EVENT=push \ + -e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \ + -e DRONE_COMMIT_BRANCH=master \ + drone/git +``` diff --git a/posix/clone b/posix/clone index 11f88fd..407c43a 100755 --- a/posix/clone +++ b/posix/clone @@ -32,10 +32,19 @@ fi # configure git global behavior and parameters via the # following environment variables: -export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME=drone} -export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost} -export GIT_COMMITTER_NAME=${GIT_AUTHOR_NAME} -export GIT_COMMITTER_EMAIL=${GIT_AUTHOR_EMAIL} + +if [[ -z "${GIT_AUTHOR_NAME}" ]]; then + export DRONE_COMMIT_AUTHOR_NAME=drone +fi + +if [[ -z "${GIT_AUTHOR_EMAIL}" ]]; then + export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost +fi + +export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME} +export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL} +export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME} +export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL} # GIT_SSL_NO_VERIFY= diff --git a/posix/clone-pull-request b/posix/clone-pull-request index 10b309e..e73352a 100755 --- a/posix/clone-pull-request +++ b/posix/clone-pull-request @@ -17,4 +17,4 @@ git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}: git checkout ${DRONE_COMMIT_BRANCH} git fetch origin ${DRONE_COMMIT_REF}: -git rebase ${DRONE_COMMIT_SHA} +git merge ${DRONE_COMMIT_SHA}