Last active
December 13, 2015 18:09
-
-
Save chmouel/4953688 to your computer and use it in GitHub Desktop.
On current directory if they are git update them if on master or fecth them on other branch and print the one who didn't get merged with origin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
set -e | |
PROCESS_DIR=${1} | |
[[ -n ${GIT_DIRS} && -z ${PROCESS_DIR} ]] && PROCESS_DIR=${GIT_DIRS} | |
typeset -A notprocessed | |
autoload -U colors | |
for gitdir in ${PROCESS_DIR};do | |
for i in $gitdir/*/.git(:h);do | |
pushd ${i} >/dev/null; | |
branch=${${"$(<.git/HEAD)"#ref: }#refs/heads/} | |
[[ ${branch} == master ]] && cmd="pull" || { | |
cmd="fetch"; | |
notprocessed[$i]=$branch | |
} | |
git ${cmd} origin master | |
popd >/dev/null | |
done | |
done | |
[[ -z ${notprocessed} ]] && exit | |
echo $fg[red]Not updated on master only fetch$fg[default] | |
for k in ${(k)notprocessed};do | |
echo $k : $notprocessed[$k] | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment