From 015536eef6c68088b48b61e06378ea3cab70acf5 Mon Sep 17 00:00:00 2001 From: Simon Marsh Date: Tue, 27 Jul 2021 20:14:03 +0100 Subject: [PATCH] re-order squash-my-commit script to count commits before rebasing --- squash-my-commits | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/squash-my-commits b/squash-my-commits index 038b73e84..8fce5ac3d 100755 --- a/squash-my-commits +++ b/squash-my-commits @@ -110,31 +110,6 @@ fi ########################################################################## -if [ "$verify_only" -ne 1 ] -then - - # ensure the local branch is up to date - echo 'Rebasing local changes against the registry master' - git fetch dn42registry master - if [ $? -ne 0 ] - then - echo 'ERROR: Failed to fetch registry master branch' - echo 'Hint: you can use --ssh/--https to force use of ssh or https' - echo 'If all else fails, you can also set the DN42_REG_URL' - echo 'environment variable to directly specify the URL to fetch' - exit 1 - fi - - # fail on errors from here onwards - set -e - - git rebase dn42registry/master -else - set -e -fi - -########################################################################## - # find number of local commits count=$(git rev-list --count HEAD ^dn42registry/master) @@ -151,6 +126,24 @@ then exit 1 fi +# ensure the local branch is up to date +echo 'Rebasing local changes against the registry master' +git fetch dn42registry master +if [ $? -ne 0 ] +then + echo 'ERROR: Failed to fetch registry master branch' + echo 'Hint: you can use --ssh/--https to force use of ssh or https' + echo 'If all else fails, you can also set the DN42_REG_URL' + echo 'environment variable to directly specify the URL to fetch' + exit 1 +fi + +# fail on errors from here onwards +set -e + +# do the rebase thing +git rebase dn42registry/master + echo 'Squashing $count commits ...' # construct a new comment based on previous commits