Created
September 23, 2018 01:15
-
-
Save kytulendu/4bf32bf07537754dc0ddfde63099a45d to your computer and use it in GitHub Desktop.
A shell script for update all git, hg and svn below current directory or specified directory.
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, hg and svn directories below current directory or specified directory | |
# Skips directories that contain a file called .ignore | |
HIGHLIGHT="\e[01;34m" | |
NORMAL='\e[00m' | |
process_dir() { | |
local d="$1" | |
echo "Scanning:$1" | |
if [ -d "$d" ]; then | |
if [ -e "$d/.ignore" ]; then | |
echo -e "${HIGHLIGHT}Ignoring:$d${NORMAL}" | |
else | |
#echo "Entering: $d" | |
cd "$d" > /dev/null | |
if [ -d ".git" ]; then | |
echo -e "${HIGHLIGHT}Updating:`pwd`${NORMAL}" | |
# revert changes in working copy | |
git checkout . | |
git pull | |
else | |
if [ -d ".svn" ]; then | |
echo -e "${HIGHLIGHT}Updating:`pwd`${NORMAL}" | |
svn update | |
else | |
if [ -d ".hg" ]; then | |
echo -e "${HIGHLIGHT}Updating:`pwd`${NORMAL}" | |
hg pull | |
hg update | |
else | |
scan "${PWD}" | |
fi | |
fi | |
fi | |
cd .. > /dev/null | |
fi | |
fi | |
#echo "Exiting `pwd`" | |
} | |
function scan { | |
#echo "Current directory: `pwd`" | |
for x in "$1"/*; do | |
if [ -d "$x" ]; then | |
process_dir "$x" | |
fi | |
done | |
} | |
#clear | |
scan "${PWD}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment