Created
December 7, 2010 20:33
-
-
Save mdb/732362 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Running this script via ./smartcommit.sh provides a fast way | |
# to selectively include files in an 'svn commit.' | |
# The script can be used as follows: | |
# | |
# 1. Enter ./smartcommit.sh at the command line from within the project's directory | |
# 1. A temporary file containing an 'svn status' list is opened in Vim | |
# 2. Remove any lines specifiying files you DO NOT want to commit | |
# 3. Enter :wq in command mode to save and quit the temporary file | |
# 4. Proceed with the commit as normal, noting that only those files left | |
# listed in in the aforementioned temporary file will be committed | |
# | |
# Alternatively, you can copy and paste the following function into your | |
# ~/.bash_profile, but remember to remove the # at each line's beginning. | |
# | |
# Once this function lives in your .bash_profile, the function can be run | |
# with the command 'smartcommit.' | |
# | |
# function smartcommit() { | |
# svn stat > /tmp/svn_commits.tmp | |
# vim /tmp/svn_commits.tmp | |
# svn commit `cat /tmp/svn_commits.tmp | cut -d' ' -f2- | xargs` | |
# rm /tmp/svn_commits.tmp | |
# } | |
svn stat > /tmp/svn_commits.tmp | |
vim /tmp/svn_commits.tmp | |
svn commit `cat /tmp/svn_commits.tmp | cut -d' ' -f2- | xargs` | |
rm /tmp/svn_commits.tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I liked your idea but had some additional criteria:
function cleanup {
rm /tmp/svn_commits.tmp /tmp/svn_commits.md5 2> /dev/null #cleanup, redirect stops it complaining when the files aren't there.
}
trap cleanup EXIT #always cleanup when the script exits.
svn stat > /tmp/svn_commits.tmp
[ ! -s /tmp/svn_commits.tmp ] && echo "Nothing to commit, quitting." && exit
md5 /tmp/svn_commits.tmp > /tmp/svn_commits.md5 #Used later to detect if the file changes
vim /tmp/svn_commits.tmp #User can now edit the commit list
md5 /tmp/svn_commits.tmp | diff /tmp/svn_commits.md5 - > /dev/null && read -p "No changes were made, did you want to quit? [CTRL+C quit | ENTER proceed]
" #newline
svn add
grep -e "^\?" /tmp/svn_commits.tmp | cut -c9- | xargs
#the cut -c9- removes the first 9 columns, which represent svn statuses, seesvn help st
svn commit
cut -c9- /tmp/svn_commits.tmp | xargs