#!/bin/bash ############################################################################ # # Script for adding all new files in a directory structure to an SVN # repository. # # copyright © 2007 Pontus Östlund # # The svnadd script is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # The svnadd script is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # ############################################################################ while getopts "s:f:h" opts do case $opts in s) skip="$OPTARG";; f) if [ -f "$OPTARG" ]; then skip=$(head -n 1 $OPTARG) else echo "$OPTARG doesn't exist!" fi ;; h) help=1;; esac done shift $(($OPTIND - 1)) if [ -z $1 ] || [ "$help" ]; then echo "About: svnadd enables you to add all new files in [dir] to a "\ "subversion repository" echo "Usage: svnadd [flags] [dir]" echo echo " -s Regexp pattern for files to skip" echo " -f Path to file containing regexp for files to skip" echo " The regexp should be placed in line one!" echo " [dir] The path to the repository" echo echo "Example: svnadd svnsrc/" echo "Example: svnadd -s \"tmp/.*\.xml\" svnsrc/" echo "Example: svnadd -f regexp.txt svnsrc/" echo exit 0 fi dir=$1 if [ ! -d "$dir" ]; then echo "$dir is not a directory" exit 1 fi while read status file; do if [ "$status" = "?" ]; then res=$( echo "$file" | egrep -o "$skip" ) if [ -z "$res" ]; then svn add "$file" fi fi done<