Handle 'git checkout' error gracefully

This commit is contained in:
0x1eef 2024-04-19 09:49:21 -03:00
parent 5619e94670
commit c447d7eb9d

View file

@ -19,9 +19,13 @@ change_branch()
branch=$2 branch=$2
echo "[-] Attempt to change branch: ${branch}" echo "[-] Attempt to change branch: ${branch}"
doas -u _portzap "${git}" fetch "${remote}" > /dev/null 2>&1 doas -u _portzap "${git}" fetch "${remote}" > /dev/null 2>&1
doas -u _portzap "${git}" checkout "${branch}" > /dev/null 2>&1 || if ! doas -u _portzap "${git}" checkout "${branch}" > /dev/null 2>&1 ||
doas -u _portzap "${git}" checkout -t "${remote}"/"${branch}" > /dev/null 2>&1 doas -u _portzap "${git}" checkout -t "${remote}"/"${branch}" > /dev/null 2>&1; then
echo "[-] Done" echo "[-] 'git checkout' exited with an error"
exit 1
else
echo "[-] Done"
fi
set -e set -e
} }