Skip to content

Commit 39d372f

Browse files
committed
squash-branch: fix num_commits
1 parent 5372f7c commit 39d372f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/squash-branch

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Defaults
44
TARGET_BRANCH="gh-pages"
5-
NUM_COMMITS="5"
5+
declare -i NUM_COMMITS=5
66
REMOTE="origin"
77

88
function die()
@@ -39,9 +39,10 @@ set -x
3939

4040
# Preconditions
4141
test -f .git/config || die "Not a git workdir"
42+
test "${NUM_COMMITS}" -gt "0" || die "Not enough commits"
4243

4344
OLD_TARGET_BRANCH="old-${TARGET_BRANCH}"
44-
INITIAL_REV="${OLD_TARGET_BRANCH}~${NUM_COMMITS}"
45+
INITIAL_REV="${OLD_TARGET_BRANCH}~$((NUM_COMMITS-1))"
4546

4647
# Starting point
4748
git fetch ${REMOTE}

0 commit comments

Comments
 (0)