Skip to content

Commit de95390

Browse files
committed
fix: correct checkout behavior
Signed-off-by: Kevin O'Donnell <kevin@blockchaintp.com>
1 parent 297a587 commit de95390

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bash/switch-to-branch

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ options::description "Switch all of the the branch of all of the target\
2828
options::add -o c -d "client repository set" -a -e CLIENT
2929
options::add -o o -d "target organization" -a -m -e ORG
3030
options::add -o b -d "branch to switch to" -a -m -e BRANCH
31+
options::add -o n -d "if this is a new branch" -x NEW_BRANCH
3132
options::parse "$@"
3233
shift $((OPTIND - 1))
3334

@@ -45,7 +46,10 @@ for d in "$TARGET_DIR"/*; do
4546
log::warn "Cannot cd to $d"
4647
continue
4748
fi
48-
if exec::hide git::cmd checkout -b "$BRANCH" "$@"; then
49+
if [ "$NEW_BRANCH" = "true" ] && exec::hide git::cmd checkout -b \
50+
"$BRANCH" "$@"; then
51+
log::info "Checked out into new branch $BRANCH in $d"
52+
elif exec::hide git::cmd checkout "$BRANCH" "$@"; then
4953
log::info "Checked out $BRANCH in $d"
5054
else
5155
log::warn "Failed to checkout branch $BRANCH in $d"

0 commit comments

Comments
 (0)