3

Committing file gives Warning: post-commit hook failed (exit code 255) with no output. No email is sent out too. My hooks/post-commit file has the following content

#!/bin/sh

REPOS="$1"
REV="$2"

"$REPOS"/hooks/mailer.py commit "$REPOS" $REV "$REPOS"/mailer.conf

How could I manually run that file to troubleshoot the problem? my mailer.py file is located under hooks folder too and mailer.conf is located outside of hooks folder.

user1076881
  • 241
  • 7
  • 15

1 Answers1

3

How could I manually run that file to troubleshoot the problem? my mailer.py file is located under hooks folder too and mailer.conf is located outside of hooks folder.

That's simple: Simply run the command manually.

$ cd $REPOS   #Where ever that is...
$ REV=230     #Whatever the revision number is

$ hooks/mailer.py commit . $REV mailer.conf

You can copy the mailer.py into another file, and play around with it. Add a few print statements, run it in the debugger, etc. For example, you probably want to futz the actual mail part of your program not to really mail everything out to the developers until you're ready to debug the particular sending mechanism. Developers don't like their mailboxes bombarded with a bunch of post-commit hook tests.

$ cp hooks/mailer.py hooks/mailer2.py
$ cp mailer.conf mailer2.conf
$ hooks/mailer2.py commit . $REV mailer.conf

What I'd suggest is that you disable your post-commit hook (in Unix/Linux, take off the executable bit should be sufficient, or simply rename post-commit to post-commit.temp). then have the user commit their change.

Once the change is committed, you have the revision number of the commit that caused the problem. Now, you can use that revision number when you manually run your post-commit hook.


Helpful Hint

If you're making a pre-commit hook, allow the hook to take either a transaction number or a revision number:

# Transaction number in pre-commit script:

REPOS="$1"
TRX="$2"

"$REPOS/hooks/myscript" -t $TRX "$REPOS"

From the command line:

 cd $REPOS
 hooks/myscript -r $REVISION .

This way, you can debug your pre-commit hook with already committed revisions. This is much, much easier than trying to debug by committing the same change over and over again.

Community
  • 1
  • 1
David W.
  • 105,218
  • 39
  • 216
  • 337
  • Thanks David, I would try that out. What should be the correct permission given to file mailer.py? – user1076881 Feb 27 '12 at 23:33
  • it is currently -rw-rw-r-x 1 user grp mailer.py – user1076881 Feb 27 '12 at 23:41
  • @user1076881 Interesting question. The user who executes the server process (and probably the file owner) must have execute permission. Assuming the same as file owner, it should be -rwx??????. The rest doesn't really matter. It could be -rwxr-xr-x (0755) or -rwxr--r-- (744) or even -rwx------ (700). The point is that the owner should be able to execute the file. Do `chown 755 mailer.py`. Also make sure that file is owned by the user who owns the repo, and is the same user who executes the svn server process. – David W. Feb 28 '12 at 03:12