Last active
July 9, 2019 04:55
-
-
Save mnot/5023210 to your computer and use it in GitHub Desktop.
Update all projects in a directory from their master repositories.
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 | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
for PROJECT in $DIR/* | |
do | |
if [ -d $PROJECT ] ; then | |
cd $PROJECT | |
# Git | |
if [ -d .git ] ; then | |
git_status="$(git status 2> /dev/null)" | |
if [[ ${git_status} =~ "working directory clean" || ${git_status} =~ "Untracked files" ]] ; then | |
echo -e "*** $PROJECT - pulling" | |
git pull -q | |
else | |
echo -e "*** \033[1;33m$PROJECT - changes present\033[0m" | |
fi | |
fi | |
# Subversion | |
if [ -d .svn ] ; then | |
echo -e "*** $PROJECT - updating" | |
svn up | |
fi | |
cd .. | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment