SVN Auto Commit Bash Script
Join the DZone community and get the full member experience.Join For Free
A convenient way to make auto commits when the files change. You need the svn client to make this script work. Add it as a startup script and worry no more.
#!/bin/bash # Run commit every second. # Why? Cron can't do that. # This can be used combined with a post-commit hook to make a kind of a versioned FTP :P # This script needs a initial checkout! A working copy must exist a priori! # You need to set-up a "svn-path" file in the same directory as the script with one working copy a line # /absolute/working-copy/ # /absolute/working-copy2/ # Bugs: # Sometimes when you work with someone else on the same file it can overwrite others modifications with yours without throwing a conflict # Good thing it's svn and you can easily merge the modifications afterwards. Still this bug is annoying # Change this to your paths script_path="/home/sasha/Scripts/" paths_file="/home/sasha/Scripts/svn-paths" while [ true ]; do message="*Auto-message*" for local_path in `cat $paths_file| grep -v "#"`; do stat=`svn status $local_path` if [[ $stat != '' ]]; then #Are there any changes? delete_files=`echo $stat|grep -e "^\!"|cut -d" " -f2` if [[ $delete_files != '' ]]; then svn delete $delete_files>/dev/null 2>/dev/null svn commit --non-interactive -m "$message (delete)" $remote_url >/dev/null 2>>"$script_path"commit_log fi # Do we have any files to add add_files=`echo $stat|grep -e "^\?"|cut -d" " -f2` if [[ $add_files != '' ]]; then svn add $add_files >/dev/null 2>/dev/null # Add new files if there are any svn commit --non-interactive -m "$message (add)" $remote_url >/dev/null 2>>"$script_path"commit_log # Finaly commit fi svn update $local_path >/dev/null 2>>/dev/null #Checkout first svn commit --non-interactive -m "$message (modified)" $local_path >/dev/null 2>>"$script_path"commit_log # Finaly commit fi done sleep 1 done
Commit (data management) Bash (Unix shell)
Opinions expressed by DZone contributors are their own.