Skip to content

Instantly share code, notes, and snippets.

@vartec
Last active August 3, 2022 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vartec/d09990a2078f7050118da812652a57b3 to your computer and use it in GitHub Desktop.
Save vartec/d09990a2078f7050118da812652a57b3 to your computer and use it in GitHub Desktop.
#!/bin/zsh
find $WORK_DIR_PATH -name .git | sed s/'.git'// | xargs -P64 -I{} zsh -c 'cd {} && git fetch -j 10 &> /dev/null'
for DIR in $WORK_DIR_PATH/*; do
BASENAME=$(basename $DIR)
echo -n "\e[92mUpdating: \e[1m$BASENAME\e[0m "
pushd $DIR
if [[ ! -d .git ]]; then
echo "\e[93mnot a git repo, skipping... \e[0m"
continue
fi
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [[ "$BRANCH" = 'master' || "$BRANCH" = 'main' ]]; then
if OUTPUT=$(git status --porcelain) && [ -z "$OUTPUT" ]; then
git pull -q
else
echo -n "\e[91mnot clean: \e[1m\n$OUTPUT\e[0m"
fi
else
echo -n "\e[91mnot on main, current branch: \e[1m$BRANCH\e[0m"
fi
popd
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment