Fix exit with error if master or main aren't found

This commit is contained in:
RealStickman 2022-09-02 15:49:00 +02:00
parent 9ee1c17c38
commit 10e27b5c17

View File

@ -17,15 +17,18 @@ for dir in "${dirs[@]}"; do
# change into that directory # change into that directory
cd "$dir" cd "$dir"
# try to check out master or main branch # try to check out master or main branch
set +e
git checkout -q master 2>/dev/null \ git checkout -q master 2>/dev/null \
|| git checkout -q main 2>/dev/null || git checkout -q main 2>/dev/null
# check whether the previous two commands failed # check whether the previous two commands failed
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
printf "Couldn't find master or main branches\n" printf "Couldn't find master or main branch\n"
exit 1 # if all is well, fetch and pull
else
git fetch --all
git pull
fi fi
git fetch --all set -e
git pull
done done
exit 0 exit 0