Git hooks.

I finally decide to git hooks a try.

My goal is after I commit. run tests and email me the result.

I find a tutorial, think post-update is the way to go.

So I tried with the following code, make some change and commit. but it does not work.


#!/bin/sh
# send email
/usr/games/fortune | mail -s "git commited" email@gmail.com

As usual, I stackoverflow. some hints is that the GIT_DIR probably not right.

So I change it, still no lucky.


#!/bin/sh
# send email
GIT_DIR=/home/hwu/downstream/
/usr/games/fortune | mail -s "git commited" email@gmail.com

At this point, I am a bit angry, why it is so hard to complish such a simple thing?

There seems no easy matrials I can rely on.

Seems whatever I do, git post-update hook do nothing.

I wonder maybe the post-update hook is not the right one, when I find that most of the topic is about pull, update when talking about post-update.

Finally, I switch to post-commit and it works.

The Whole process take me about 1 hour.

Once this works, I will add my code to do the test. That part shoud be easy