Created
December 15, 2012 01:16
-
-
Save mslinn/4290222 to your computer and use it in GitHub Desktop.
Commits all git and svn directories below current directory or specified directory
Skips directories that contain a file called .ignore
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 | |
# Commits all git and svn directories below current directory or specified directory | |
# Skips directories that contain a file called .ignore | |
HIGHLIGHT="\e[01;34m" | |
NORMAL='\e[00m' | |
REPO=origin | |
MSG="-" | |
while getopts "dm:\?" opt; do | |
case $opt in | |
d ) set -xv ;; | |
m ) MSG="$OPTARG" ;; | |
h ) help ;; | |
\?) help ;; | |
esac | |
done | |
shift $(($OPTIND-1)) | |
function commit { | |
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}Committing `pwd`$NORMAL" | |
git add -A; git commit -m "$MSG"; git push $REPO | |
elif [ -d ".svn" ]; then | |
echo -e "\n${HIGHLIGHT}Committing `pwd`$NORMAL" | |
svn commit -m "$MSG" | |
else | |
scan * | |
fi | |
cd .. > /dev/null | |
fi | |
fi | |
#echo "Exiting commitAll: pwd=`pwd`" | |
} | |
function scan { | |
#echo "`pwd`" | |
for x in $*; do | |
commit "$x" | |
done | |
} | |
if [ "$1" != "" ]; then cd $1 > /dev/null; fi | |
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