[Last Call] Learn how to a build a cloud-first strategyRegister Now


Subversion pre-commit hook

Posted on 2006-05-02
Medium Priority
Last Modified: 2013-12-16
Hi I use TortoiseSVN on Windows and have a running SVN Server without apache just the svn daemon.

I need a pre-commit hook that forces users to make a log entry.
The example file of the pre-commit hook contains code for this but it doesn't work.
When I use the example file for real I cannot commit with or withour log message.

Furthermore I don't get the stdErr that should be passed to the Client.
It just says that the commit has failed but without giving the reason that is printed to stdErr.

Here is the code I'm using right now and which doesn't work in any way.


# Make sure that the log message contains some text.
$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" > /dev/null || exit 1

# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1

# All checks passed, so allow the commit.
exit 0

I need a hook script that
a) works
b) passes the stdErr to the client so that the User knows why the commit has failed.
Question by:michi3012

Author Comment

ID: 16584457
Btw. I know that Tortoise offers me to configure an option to prevent the user to commit without a log message.
But I also use AnkhSVN as the Visual Studio Plugin and I wasn't able to find an option for Ankh to behave.....
Maybe there is a possibility in the config file but I couldn't figure it out.
LVL 15

Accepted Solution

m1tk4 earned 2000 total points
ID: 16586441
I'd start with:

1. Verifying that /usr/bin/svnlook is there
2. Verifying that commit-access-control.pl is there
3. replacing one "exit 1" with "exit 0"  at a time in these two checks and finding out which one actually fails

To echo something to a stderr from this script use

echo "Comment required" >&2


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question