开发者

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

开发者 https://www.devze.com 2023-03-30 11:19 出处:网络
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开发者_如何学Python

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

精彩评论

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