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.
Best Answer
That's simple: Simply run the command manually.
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.
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
topost-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:
From the command line:
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.