Skip to content

Commit

Permalink
auto detect master/main branch while updating
Browse files Browse the repository at this point in the history
  • Loading branch information
mpostaire committed Apr 11, 2022
1 parent db8cea8 commit b1a92c8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ztupide.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ _ztupide_remove() {

_ztupide_update() {
echo "checking ${1:t} for updates..."
git -C ${1} fetch origin master --quiet
[ -z "$(git branch --list main)" ] && local branch="main" || local branch="master"
git -C ${1} fetch origin "${branch}" --quiet
local local=$(git -C ${1} rev-parse HEAD)
local base=$(git -C ${1} rev-parse '@{u}')
if [ "${local}" != "${base}" ]; then
git -C ${1} reset --hard origin/master
git -C ${1} pull origin master --quiet
git -C ${1} reset --hard origin/"${branch}"
git -C ${1} pull origin "${branch}" --quiet
echo "${1:t} updated"
fi
}
Expand Down

0 comments on commit b1a92c8

Please sign in to comment.