Skip to content

Commit ac0341a

Browse files
committed
Stop parameter for multi-commit mode when the base branch was already updated
I left it out not working sorry!
1 parent ebe1af3 commit ac0341a

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

bin/git-update-parent-branch

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
CURRENT_BRANCH="$(git current-branch)"
44
PARENT_BRANCH=""
55
COMMIT_MODE="multi-commit"
6+
UNTIL_COMMIT=""
67
COMMITS=""
78

89
while getopts ":-:" opt; do
@@ -30,6 +31,10 @@ else
3031
COMMON_ANCESTOR="$(git merge-base "$CURRENT_BRANCH" "$PARENT_BRANCH")"
3132
COMMITS="$(git rev-list "$CURRENT_BRANCH"..."$COMMON_ANCESTOR")"
3233
fi
34+
35+
if [ "$2" != "" ]; then
36+
UNTIL_COMMIT="$2"
37+
fi
3338
fi
3439
# TODO - What if we don't have commits?
3540

@@ -52,12 +57,29 @@ if [ "$COMMIT_MODE" == "single-commit" ]; then
5257
echo "Cherry Picking -> $COMMITS"
5358
git cherry-pick "$COMMITS"
5459
else
55-
COMMIT_ARRAY=($COMMIT_LIST)
56-
for commit_id in "${COMMIT_ARRAY[@]}"
57-
do
60+
echo 'Multi Commit Mode Enabled!'
61+
COMMIT_ARRAY=($COMMITS)
62+
COMMITS_TO_CHERRY=()
63+
64+
if [ "$UNTIL_COMMIT" != "" ]; then
65+
for commit_id in "${COMMIT_ARRAY[@]}"
66+
do
67+
if [ "$UNTIL_COMMIT" == "$commit_id" ]; then
68+
break
69+
fi
70+
COMMITS_TO_CHERRY+=("$commit_id")
71+
done
72+
fi
73+
74+
size=${#COMMITS_TO_CHERRY[@]}
75+
for (( i=size-1; i>=0; i-- )); do
5876
echo "----"
59-
echo "Cherry Picking -> $commit_id"
60-
git cherry-pick "$commit_id"
77+
if [ "$UNTIL_COMMIT" == "${COMMITS_TO_CHERRY[i]}" ]; then
78+
echo "NOT Cherry Picking! -> ${COMMITS_TO_CHERRY[i]}"
79+
else
80+
echo "Cherry Picking -> ${COMMITS_TO_CHERRY[i]}"
81+
git cherry-pick "${COMMITS_TO_CHERRY[i]}"
82+
fi
6183
done
6284
fi
6385

0 commit comments

Comments
 (0)