git post-receive hook that grabs commit messages and posts back to URL

后端 未结 1 1424
悲哀的现实
悲哀的现实 2020-12-10 15:57

We are using a ticketing system that I want to automatically update as developers push their changes to the server. In order to update it, I only need to provide a specific

相关标签:
1条回答
  • 2020-12-10 16:33

    The main PITA is to isolate the correct list of new revisions, which I borrowed from /usr/share/doc/git/contrib/hooks/post-receive-email(show_new_revisions).

    while read oval nval ref ; do
        if expr "$ref" : "^refs/heads/"; then
            if expr "$oval" : '0*$' >/dev/null
            then
                revspec=$nval
            else
                revspec=$oval..$nval
            fi
            other_branches=$(git for-each-ref --format='%(refname)' refs/heads/ |
                grep -F -v $ref)
    
            # You may want to collect the revisions to sort out
            # duplicates before the transmission to the bugtracker,
            # but not sorting is easier ;-)
            for revision in `git rev-parse --not $other_branches | git rev-list --stdin $revspec`; do
                        # I don't know if you need to url-escape the content
                        # Also you may want to transmit the data in a POST request,
                wget "http://server.com/logthis.asp?msg=$(git log $revision~1..$revision)"
            done
        fi
    done
    
    0 讨论(0)
提交回复
热议问题