svncheck: SVN Commit Audit over Multiple Projects
by Dave Tufts - March 12, 2008 / 1:52pm
My life is now in SVN. Work projects are under Subversion's control. Status reports are in SVN. Personal projects are in SVN. It's great.
The only problem with so many repositories is remembering to check in all my updates.
My SVN environment consists of Mac OS X, scplugin, and built-in Terminal commands.
Throughout the day, I may edit 4–5 repositories. Inevitably, there's a chance of forgetting to commit. Using scplugin, I could manually right-clicking on each directory. That sounds tedious. Using the terminal, I could manually execute svn stat [directory]. That would be just as time consuming.
Hello svncheck.
I wrote this simple shell script to loop through all sub-directories in my SVN root and tell me if anything, across any project, needs to be committed. It assumes that you're organized enough to keep all SVN projects under a common parent-directory. The default script loops through ~/svn/.
Installation (OS X)
- Copy the script below to a text file
- Name it
svncheckand save it on your Desktop. -
Open a terminal and execute the following.
chmod 755 ~/Desktop/svnchecksudo mv ~/Desktop/svncheck /usr/local/bin/svncheck
Usage
Open your terminal and type svncheck. If the terminal doesn't return anything, you're all good — all your files are checked in.
If you see something like this…
M massbio.org/trunk/css/site.css M status.imarc.net/trunk/dave-status.xls M status.imarc.net/trunk/dave-people.xls
…that's telling you that one file in the 'massbio.org' repository and two files in the 'status.imarc.net' repository need to be committed.
svncheck doesn't commit your files. It just acts as an audit of all repositories, reporting any files that have been updated but not checked in.
svncheck: The Script
Here's the script. You'll notice the default SVN_HOME parameter is set to '~/svn'. If you keep repositories somewhere else, change this default. Otherwise you'll have execute something like svncheck /path/to/your/svn/root
#!/bin/sh
#
# svncheck runs 'svn stat' on each directory in your SVN root.
# If you work on multiple projects throughout the day, it's a
# quick way to check if any project needs committing.
#
# USAGE
# svncheck [/path/to/svn/root]
#
SVN_HOME=$1
if [ "$SVN_HOME" == "" ]; then
SVN_HOME=${HOME}/svn/
fi;
cd ${SVN_HOME}
for i in *; do
svn stat $i
done
exit;
I run svncheck every evening before I turn my computer off. Enjoy!