Last active
August 3, 2022 00:13
-
-
Save vartec/d09990a2078f7050118da812652a57b3 to your computer and use it in GitHub Desktop.
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 | |
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