Skip to content

Instantly share code, notes, and snippets.

@chmouel
Last active December 13, 2015 18:09
Show Gist options
  • Save chmouel/4953688 to your computer and use it in GitHub Desktop.
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.
#!/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