Not able to detect branch from Git post-receive hook

前端 未结 5 1532
面向向阳花
面向向阳花 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:16

    The post-receive hook gets the same data as the pre-receive and not as arguments, but from stdin. The following is sent for all refs:

    oldRev (space) newRev (space) refName (Line feed)

    You could parse out the ref name with this bash script:

    while read oldrev newrev ref
    do
        echo "$ref"
    done
    

提交回复
热议问题