Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make subversion always abort on empty commit message without modifying the server config

Tags:

svn

svn commit from the command line pulls up my editor for me to 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) the continue or edit options. And, since I usually run the commit in the background, having to remember to fg it in order to answer the question is annoying. I regularly get the bash: a: command not found error.

I would like svn to not ask and always abort (like git does). Is there a configuration option for this?

Edit: I am using a repository at work that I share with more than 1K other developers and I am not an admin. So I need the auto-abort to work without modifying the server or its configuration.

like image 422
Eponymous Avatar asked Apr 17 '26 06:04

Eponymous


1 Answers

You can use a pre-commit hook to abort on empty commit messages. It's not too difficult, and I believe Subversion comes with a template pre-commit hook that does this.

Use the svnlook log command to pull up the commit comment. If it's empty, you can exit with a non-zero exit code and the commit won't work. You can also print something to STDERR which the committer will see, so they know why their commit was rejected. Something like this:

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 that is a way more powerful, and can set who has permission to modify or add particular files, that properties are set correctly, and that the commit message is in the correct format. you can take a look at that.

like image 172
David W. Avatar answered Apr 18 '26 21:04

David W.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!