Created
August 1, 2018 05:40
-
-
Save Flowkap/2aee3fe131c76df5ad5159b19779c75a 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/bash | |
# Update all git directories below current directory or specified directory | |
# Skips directories that contain a file called .ignore | |
# | |
# Originally: https://stackoverflow.com/questions/11981716/how-to-quickly-find-all-git-repos-under-a-directory | |
HIGHLIGHT="\e[01;34m" | |
NORMAL='\e[00m' | |
OPERATION=status | |
if [ "$1" != "" ]; then OPERATION=$1 > /dev/null; fi | |
function update { | |
local d="$1" | |
if [ -d "$d" ]; then | |
if [ -e "$d/.ignore" ]; then | |
echo -e "\n${HIGHLIGHT}Ignoring $d${NORMAL}" | |
else | |
cd $d > /dev/null | |
if [ -d ".git" ]; then | |
echo -e "\n${HIGHLIGHT}Updating `pwd`$NORMAL" | |
# echo $operation | |
git $OPERATION | |
else | |
scan * | |
fi | |
cd .. > /dev/null | |
fi | |
fi | |
} | |
function scan () { | |
for x in $*; do | |
update "$x" operation=$operation | |
done | |
} | |
echo -e "${HIGHLIGHT}Scanning ${PWD}${NORMAL}" | |
scan * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment