From dabafcd708b91a0300e7fb94adc1fe9c0a50ee40 Mon Sep 17 00:00:00 2001 From: thopic Date: Tue, 4 Jul 2023 17:54:52 +0200 Subject: [PATCH] Update post-receive hook to avoid unwanted merge --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0a2ee61..b3e61f0 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,16 @@ do # only checking out the master (or whatever branch you would like to deploy) if [ "$ref" = "refs/heads/master" ]; then - echo "Ref $ref received. Deploying master branch to production..." cd $TARGET unset GIT_DIR - git pull --ff-only $REMOTE master + PROD_BR=`git rev-parse --abbrev-ref HEAD` + if [ $PROD_BR != "master" ]; + then + echo "Production repo is on $PROD_BR branch. Aborting..." + else + echo "Ref $ref (${newrev:0:7}) received. Deploying master branch to production..." + git pull --ff-only $REMOTE master + fi else echo "Ref $ref received. Doing nothing: only the master branch may be deployed on this server." fi