Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I installed svn server with apache 2 on ubuntu 10

i have created a post-commit.sh with a single 2 lines of code

repository/hooks/post-commit.sh:

#!/bin/sh
date > /tmp/post-commit.log

nothing is written to that file can anyone assist please?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

From here:

Name

post-commit — Notification of a successful commit.

Description

The post-commit hook is run after the transaction is committed, and a new revision created. Most people use this hook to send out descriptive emails about the commit or to notify some other tool (such as an issue tracker) that a commit has happened. Some configurations also use this hook to trigger backup processes.

The output from, and exit value returned by the post-commit hook program are ignored.


What you want is a pre-commit hook (kind of obvious once you think about those names):

Name

pre-commit — Notification just prior to commit completion.

Description

The pre-commit hook is run just before a commit transaction is promoted to a new revision. Typically, this hook is used to protect against commits that are disallowed due to content or location (for example, your site might require that all commits to a certain branch include a ticket number from the bug tracker, or that the incoming log message is non-empty).

If the pre-commit hook program returns a non-zero exit value, the commit is aborted, the commit transaction is removed, and anything printed to stderr is marshalled back to the client.


Also, make sure to make the script file executable, and use the exact name pre-commit or post-commit, i.e. without file name extension!

share|improve this answer
1  
@Jason Did you make it executable? chmod +x repository/hooks/post-commit.sh? Also, try removing the .sh file name extension, I'm not sure if it works with these. –  Daniel Beck Apr 23 '11 at 10:49
    
correct had to remove the .sh –  Jason Apr 23 '11 at 10:59
    
Re quote #1: The post-commit script itself does not output anything; the output made by date is redirected internally. –  grawity Apr 23 '11 at 12:47
    
@grawity He redirects manually to a file. While stdout and stderr are probably discarded/redirected, I don't think this output is removed. Otherwise these scripts will have a hard time doing anything. –  Daniel Beck Apr 23 '11 at 12:50

Try renaming the script to repository/hooks/post-commit. The should be no extension in the filename. Read the repository/hooks/post-commit.tmpl file for more information (specifically the first paragraph which states:

The post-commit hook is invoked after a commit. Subversion runs this hook by invoking a program (script, executable, binary, etc.) named 'post-commit'

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.