From aac3ba4d432d57733420a7ab5d680cfb90aa1ccd Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Wed, 31 Jan 2018 12:54:26 -0500 Subject: [PATCH] automerge: add option to start with a reset * admin/automerge (usage): Mention -r. (reset): New variable. (-r): New option. (main): If requested, do a reset and pull. --- admin/automerge | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/admin/automerge b/admin/automerge index 94b41d2cdca..218ecb067c7 100755 --- a/admin/automerge +++ b/admin/automerge @@ -27,8 +27,7 @@ ## and then push it. ## Intended usage: ## Have a dedicated git directory just for this. -## Have a cron job that does a hard reset (to clean up after any -## previous failures), then a git pull, then calls this script with -p. +## Have a cron job that calls this script with -r -p. die () # write error to stderr and exit { @@ -51,15 +50,16 @@ cd ../ usage () { cat 1>&2 < /dev/null" EXIT } +[ "$reset" ] && { + echo "Resetting..." + git reset --hard origin/master || die "reset error" + + echo "Pulling..." + git pull --ff-only || die "pull error" +} + + rev=$(git rev-parse HEAD) [ $(git rev-parse @{u}) = $rev ] || die "Local state does not match origin" -- 2.39.2