From 6d751578191f533e60f1468cc30e14a47229d98b Mon Sep 17 00:00:00 2001 From: Simon Marsh Date: Thu, 19 Aug 2021 10:01:57 +0100 Subject: [PATCH] Fetch from master before counting number of commits --- squash-my-commits | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/squash-my-commits b/squash-my-commits index 8fce5ac3d..0f133948b 100755 --- a/squash-my-commits +++ b/squash-my-commits @@ -110,8 +110,26 @@ fi ########################################################################## +# ensure the local branch is up to date +echo "Fetching dn42registry 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 + # find number of local commits count=$(git rev-list --count HEAD ^dn42registry/master) +if [ $? -ne 0 ] +then + echo "ERROR: Failed to find the number of local commits" + echo "Please report this as a bug to the registry maintainters" + exit 1 +fi # if there are less then 2 local commits, there's nothing to do if [ "$count" -lt 2 ] @@ -126,22 +144,11 @@ 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 +echo 'Rebasing local changes against the registry master' git rebase dn42registry/master echo 'Squashing $count commits ...'