views:

105

answers:

1

I'm using git with trac. After push I want two thing to be done:

  1. Sending email to development team with diff
  2. If there is some special phrase in commit message (like "see #1"), then I want the commit message to be placed in trac ticket.

The first thing is solved by git-commit-notifier. It works perfectly after I have created post-receive hook:

#!/bin/sh

/var/lib/gems/1.8/bin/git-commit-notifier /etc/git-commit-notifier.yml

My second requirement can be solved as discribed at http://trac-hacks.org/wiki/GitPlugin#post-receivehookscripts. It also works perfectly with such post-receive hook:

#!/bin/sh

/var/trac/testgit/commit-updater

Both 2 things works when they are separate. But I need to combine them. So I have created post-receive hook:

#!/bin/sh

/var/trac/testgit/commit-updater
/var/lib/gems/1.8/bin/git-commit-notifier /etc/git-commit-notifier.yml

It is very funny, but this is not working. The commands run perfectly well when the run separately, but only first one works when they are placed into post-receive hook.

If I have such hook:

#!/bin/sh

/var/trac/testgit/commit-updater
/var/lib/gems/1.8/bin/git-commit-notifier /etc/git-commit-notifier.yml

I do receive the following error

/var/lib/gems/1.8/gems/git-commit-notifier-0.8.0/bin/git-commit-notifier:12: undefined method `strip' for nil:NilClass (NoMethodError)
        from /var/lib/gems/1.8/bin/git-commit-notifier:19:in `load'
        from /var/lib/gems/1.8/bin/git-commit-notifier:19

But if I change to order of this 2 commands I do not receive any errors, but only the first command works.

I will appreciate any help. I'm trying to solve this problem for a long time and I have no ideas.

A: 

Assuming my comment is correct, and commit-updater is eating all of stdin, something like this should do the trick...

#!/bin/sh

FILE=mktemp
cat - > $FILE
cat $FILE | /var/trac/testgit/commit-updater
cat $FILE | /var/lib/gems/1.8/bin/git-commit-notifier /etc/git-commit-notifier.yml
rm $FILE
ngoozeff
Thank you! The only thing that I had to change in your script is to remove quotes:FILE=mktempAnd after that it works perfectly =)
bessarabov
@bessarabov: removed the backticks. thanks
ngoozeff