Created
March 25, 2011 11:23
-
-
Save niwo/886706 to your computer and use it in GitHub Desktop.
Bash script for auto-committing from a SVN working copy
This file contains hidden or 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 | |
### Settings | |
svn_wk='/srv/tftp/data/' | |
svn_user='user' | |
svn_passwd='passwd' | |
### Variables | |
date=`date +"%F %T"` | |
svn='/usr/bin/svn' | |
#### Start automatic commit | |
script_path=`dirname $(readlink -f $0)` | |
log="${script_path}/commit.log" | |
cd $svn_wk | |
stat=`svn status` | |
if [[ $stat != '' ]]; then | |
# Do we have any files to delete? | |
delete_files=`echo $stat|grep '^\!'|sed 's/\! / /g'` | |
if [[ $delete_files != '' ]]; then | |
for file in $delete_files; do | |
svn delete $file >>$log | |
done | |
fi | |
# Do we have any files to add? | |
add_files=`echo $stat|grep '^\?'|sed 's/\? / /g'` | |
if [[ $add_files != '' ]]; then | |
for file in $add_files; do | |
svn add $file >>$log | |
done | |
fi | |
#Checkout first | |
svn update #>/dev/null 2>>/dev/null | |
# Finaly commit | |
$svn commit -m "$date - Automatic Update/Commit" --username $svn_user --password $svn_passwd --non-interactive >>$log | |
fi |
There are problems with spaces in filenames! this snippet will work.
svn status | grep '^!'| sed -e 's/! / /g' -e 's/^ *//g' | while read file
do
echo "---> delete" $file
svn delete "$file" >> $log
done
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can't get files to add with that regex, should be (imho):
echo $stat|grep '^[(M)(?)]'|sed 's/[(M)(?)] / /g'