I have a post-receive hook that is written in perl. I need to be able to figure out which branch is being pushed to. How can I do this? I tried looking at @ARGV and $ARGV[2] without su开发者_如何学Pythonccess.
The key from the git documentation is that the post-receive hook receives no arguments:
This hook executes once for the receive operation. It takes no arguments, but gets the same information as the <> hook does on its standard input.
Here is some perl code that I have used to parse ref:
while (<>) {
chomp;
next unless my($old,$new,$ref) =
m/ ^ ([0-9a-f]+) \s+ # old SHA-1
([0-9a-f]+) \s+ # new SHA-1
refs\/heads\/(.*?) # ref
\s* $ /x;
#...
}
精彩评论