Not able to detect branch from Git post-receive hook

前端 未结 5 1760
面向向阳花
面向向阳花 2021-01-31 11:37

I\'ve got a post receive hook setup on the remote repo that tries to determine the branch name of the incoming push as follows:

$branch = `git rev-parse --abbrev         


        
5条回答
  •  忘掉有多难
    2021-01-31 12:08

    Both these answers are correct, but I was having trouble getting stdin to the next common function post-receive-email. Here is what I ended up with:

    read oldrev newrev ref
    echo "$oldrev" "$newrev" "$ref" | . /usr/share/git-core/contrib/hooks/post-receive-email
    
    
    if [ "refs/heads/qa" == "$ref" ]; then
      # Big Tuna YO!
      wget -q -O - --connect-timeout=2 http://127.0.0.1:3000/hooks/build/qa_now
    fi
    

提交回复
热议问题