re-order squash-my-commit script to count commits before rebasing

This commit is contained in:
Simon Marsh 2021-07-27 20:14:03 +01:00
parent bb3e7cee37
commit 015536eef6
No known key found for this signature in database
GPG key ID: 0FCCD13AE1CF7ED8

View file

@ -110,8 +110,21 @@ fi
########################################################################## ##########################################################################
if [ "$verify_only" -ne 1 ] # find number of local commits
count=$(git rev-list --count HEAD ^dn42registry/master)
# if there are less then 2 local commits, there's nothing to do
if [ "$count" -lt 2 ]
then then
echo "$count local commits found, no squash is required"
exit 0
fi
if [ "$verify_only" -eq 1 ]
then
echo "$count local commits found"
exit 1
fi
# ensure the local branch is up to date # ensure the local branch is up to date
echo 'Rebasing local changes against the registry master' echo 'Rebasing local changes against the registry master'
@ -128,28 +141,8 @@ then
# fail on errors from here onwards # fail on errors from here onwards
set -e set -e
# do the rebase thing
git rebase dn42registry/master git rebase dn42registry/master
else
set -e
fi
##########################################################################
# find number of local commits
count=$(git rev-list --count HEAD ^dn42registry/master)
# if there are less then 2 local commits, there's nothing to do
if [ "$count" -lt 2 ]
then
echo "$count local commits found, no squash is required"
exit 0
fi
if [ "$verify_only" -eq 1 ]
then
echo "$count local commits found"
exit 1
fi
echo 'Squashing $count commits ...' echo 'Squashing $count commits ...'