Skip to content

Instantly share code, notes, and snippets.

@mnot
Last active July 9, 2019 04:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnot/5023210 to your computer and use it in GitHub Desktop.
Save mnot/5023210 to your computer and use it in GitHub Desktop.
Update all projects in a directory from their master repositories.
#!/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