Skip to content

Commit 4fdab1a

Browse files
committed
move change_branch here
1 parent 9fb1b97 commit 4fdab1a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

functions_library.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ feedback() {
3737
echo -e "$(tput setaf 3)$1$(tput sgr0)"
3838
}
3939

40+
# Function checks out branch if BRANCH is defined.
41+
change_branch() {
42+
# first and only parameter is the branch to checkout
43+
44+
# -z tests for zero length.
45+
if [ -z ${1+x} ]; then
46+
echo "Working from main branch.";
47+
else
48+
echo "Working from $1 branch";
49+
# sudo git checkout -b $BRANCH
50+
# the -b creates a branch if it doesn't exist
51+
# this leads to a fatal error msg being displayed to the user
52+
# is there any case where we can to create the branch here???
53+
# https://github.com/tldr-pages/tldr/blob/master/pages/common/git-checkout.md
54+
sudo git checkout $1
55+
fi
56+
}
57+
4058
#########################################################################
4159
#
4260
# FILE EDITION

0 commit comments

Comments
 (0)