Created
March 13, 2019 15:45
-
-
Save dy-dx/c5c4f5b33f462ff91eed09872072e952 to your computer and use it in GitHub Desktop.
run git pull in all repos, unless the branch is something other than "dev" or "master"
This file contains 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/bash | |
RED="\033[0;31m" | |
YELLOW="\033[0;33m" | |
GREEN="\033[0;32m" | |
NO_COLOR="\033[0m" | |
function defaultBranch() { | |
git remote show origin | grep "HEAD branch" | sed 's/.*: //' | |
} | |
for i in */.git; do ( | |
repo="${i%/.git}" | |
cd "$repo" | |
ref="$(command git name-rev --name-only --exclude 'tags/*' HEAD)" | |
printf "%-25s #%-8s ... " "$repo" "$ref" | |
if [ "$ref" != "dev" ] && [ "$ref" != "master" ]; then | |
echo -e "${RED}Warning${NO_COLOR}" | |
echo -e "** ${GREEN}${repo}${NO_COLOR} is on branch ${YELLOW}${ref}${NO_COLOR}" | |
echo -e "** The default branch is ${YELLOW}$(defaultBranch)${NO_COLOR}\n" | |
else | |
git fetch -q origin | |
git pull --no-stat --ff-only | |
fi | |
); done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment