Skip to content

Commit

Permalink
opti for git_pull_r
Browse files Browse the repository at this point in the history
  • Loading branch information
pad92 committed Nov 23, 2022
1 parent e1514b5 commit 41ed9ca
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion zsh/functions/git.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ git_pull_r() {
for REPO in $(find $(pwd) -type d -name .git | sed 's@/.git@@g'); do
echo -ne "- ${REPO}"
RET=$(git --git-dir=${REPO}/.git pull 2>&1 )
GIT_BRANCH_CURRENT=$(git --git-dir=${REPO}/.git rev-parse --abbrev-ref HEAD)
if [ $? -ne 0 ]; then
echo -ne "\tERROR\n"
GIT_BRANCH_DEFAULT=$(git --git-dir=${REPO}/.git remote show origin | awk '/HEAD branch/ {print $NF}')
RET=$(git --git-dir=${REPO}/.git checkout ${GIT_BRANCH_DEFAULT} 2>&1)
RET=$(git --git-dir=${REPO}/.git pull 2>&1)
if [ $? -ne 0 ]; then
echo -ne "\tERROR : unable to pull ${GIT_BRANCH_DEFAULT}\n"
else
echo -ne "\tERROR : unable to pull ${GIT_BRANCH_CURRENT}, switch to ${GIT_BRANCH_DEFAULT}"
fi
echo "$(date +"%Y%m%d-%H%M") ERROR: ${REPO}" >> prune.log
echo "${RET}" >> prune.log
echo "" >> prune.log
Expand Down

0 comments on commit 41ed9ca

Please sign in to comment.