开发者

How can a post-receive hook written in perl get the branch name?

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;
   #...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜