Make subversion always abort with an empty commit message without changing the server config
svn commit
from the command line pulls up my editor so that I can write a commit message. Then, if the message is empty, it asks
Log message unchanged or not specified
(a)bort, (c)ontinue, (e)dit:
I never use (or want to use) continue or edit options. And since I usually run the commit in the background, I have to remember fg
to answer the question, this is annoying. I get the error regularly bash: a: command not found
.
I would like it svn
not to query and always interrupt (like git
does). Is there a config option for this?
Edit: I use a repository at work that I share with over 1K other developers and I am not an administrator. Therefore, I need an automatic interruption to work without changing the server or its configuration.
source to share
There is no configuration option for this. Any requirement imposed on a commit must be done with a hook script on the server.
If it's just for your own use, you can write your own wrapper script that runs your checks before calling the binary svn
to do the commit. But this will fall apart if you are using any other client on your system (like an IDE plugin).
source to share
You can use a pre-commit hook to abort on empty commit messages. It's not too hard, and I believe Subversion comes with a pre-commit hook template that does this.
Use the command svnlook log
to pull out the commit comment. If it's empty, you can exit with a nonzero exit code and the commit won't work. You can also print something to STDERR for the committer to see so they know why their commit was rejected. Something like that:
log_message=$(svnlook -t $TXN log)
if [[ -z $log_message ]]
then
echo "Your commit message was empty. Recommit with a commit message" 1>&2
exit 2
else
exit 0
fi
I have a pre-commit hook which is a more powerful way and can establish who has permission to modify or add certain files, that the properties are set correctly and the commit message is in the correct format. you can take a look at this.
source to share