Handle 'git checkout' error gracefully
Previous commit was focused on portzap-pull. This one covers portzap-clone.
This commit is contained in:
parent
bfdc145d92
commit
300dd161c2
2 changed files with 13 additions and 6 deletions
|
@ -8,6 +8,7 @@ git="${localbase}"/bin/git
|
||||||
giturl=$1
|
giturl=$1
|
||||||
gitdir=$2
|
gitdir=$2
|
||||||
branch=$3
|
branch=$3
|
||||||
|
mode="u=rwX,g=rwX,o="
|
||||||
|
|
||||||
##
|
##
|
||||||
# main
|
# main
|
||||||
|
@ -23,11 +24,17 @@ if [ -e "${gitdir}/.git" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
umask u=rwX,g=rwX,o=
|
umask "${mode}"
|
||||||
doas -u _portzap "${git}" clone "${giturl}" "${gitdir}"
|
doas -u _portzap "${git}" clone "${giturl}" "${gitdir}"
|
||||||
cd "${gitdir}"
|
cd "${gitdir}"
|
||||||
doas -u _portzap "${git}" config core.filemode off
|
doas -u _portzap "${git}" config core.filemode off
|
||||||
set +x +e
|
echo "[-] git checkout ${branch}"
|
||||||
echo "[-] Checkout ${branch}"
|
if ! doas -u _portzap "${git}" \
|
||||||
doas -u _portzap "${git}" checkout -t origin/"${branch}" > /dev/null 2>&1;
|
checkout -t \
|
||||||
echo "[-] Done"
|
origin/"${branch}" \
|
||||||
|
> /dev/null 2>&1; then
|
||||||
|
echo "[-] 'git checkout' exited with an error"
|
||||||
|
exit "${?}"
|
||||||
|
else
|
||||||
|
echo "[-] Done"
|
||||||
|
fi
|
||||||
|
|
|
@ -22,7 +22,7 @@ change_branch()
|
||||||
if ! 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; then
|
doas -u _portzap "${git}" checkout -t "${remote}"/"${branch}" > /dev/null 2>&1; then
|
||||||
echo "[-] 'git checkout' exited with an error"
|
echo "[-] 'git checkout' exited with an error"
|
||||||
exit 1
|
exit "${?}"
|
||||||
else
|
else
|
||||||
echo "[-] Done"
|
echo "[-] Done"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue