A blog about software development, primarily in Java and about web applications.

Thursday, May 8, 2008

Recursively Adding Files With Subversion

This script is for people who use the command line version of Subversion (SVN). I often use SVN's command line tools in Cygwin rather than in my IDE, eclipse. This is just Bash script that runs the svn stat command, pulls out all of the files whose status line starts with a question mark, and runs the svn add command on them.

You need to be cautious, if you have set up your svn:ignore property or your SVN config file to ingore temporary files this will blindly add them. After that, you can use the svn revert filename command to un-add them.

###
#.Name
# svnadd
#.What
# recursively finds all of the new files via the 'svn stat' command
# and runs the 'svn add' command on each one.
###

case "$1" in
-t) SVN_CMD="echo svn"
;;
-h)
echo Usage: $(basename 0) [-t|-h]
exit 1;
;;
esac

: ${SVN_CMD:=svn}

for f in $(svn stat | awk '/^?/ {print $2}')
do
$SVN_CMD add "$f"
done

1 comment:

niaodian said...

Wow...Geek stuff...