Force git to run post-receive hook, even if everything is “up-to-date”

后端 未结 9 1781
再見小時候
再見小時候 2020-11-30 19:27

How do I force git to run a post-receive hook on a server even if I don\'t have a new commit to push?

Background

I use git to aut

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 19:39

    Post-receive is the wrong place for artificial command responses.

    You want your server-side goodies in the pre-receive exit, dependent on the updated ref -- do e.g. git update-ref refs/commands/update-hooks @ on the server, then you can e.g. git push server +@:commands/update-hooks, and in the server's pre-receive you can

    while read old new ref; do case $ref in
    commands/update-hooks)
            maybe check the incoming commit for authorization
            update hooks here
            echo the results from the update
            denypush=1
            ;;
    refs/heads/master)
            extreme vetting on master-branch updates here
            ;;
    esac; done
    
    ((denypush)) && exit $denypush
    

提交回复
热议问题