Menu
Svn restores missing files at update has caused many duplicate files and wasted cleanup efforts. As a support person, unless you're lucky and the user still has the update dialog open, there's no chance to repair this after the fact. Automatic update in response to 'out of date' at commit is, correct me if.
Bash script for auto-committing from a SVN working copy
svn_autocommit.sh
#!/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 |
forfilein$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 |
forfilein$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 |
![Svn Automatic Update After Commit Svn Automatic Update After Commit](http://4.bp.blogspot.com/-LSzsAz1DXx8/TzTyMf0c_OI/AAAAAAAAGqg/GjeHj4FIxbI/s576/svn_auto_update.png)
commented Dec 16, 2013
you can't get files to add with that regex, should be (imho): echo $stat|grep '^[(M)(?)]'|sed 's/[(M)(?)] / /g' |
commented Jan 28, 2014
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 |
![Command Command](/uploads/1/2/6/5/126505198/319484253.png)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment