我们正在使用我希望在开发人员将其更改推送到服务器时自动更新的票务系统.为了更新它,我只需要提供一个特定的URL,并将提交消息作为GET变量.被调用的页面将记录此更改.我知道我的方法是使用钩子,但我不熟悉Bash和Perl所以它非常具有挑战性.
我想实现这个目标:
post-receive 钩子运行并检查哪些不同的提交是新的(因为可能有多个一次推送)curl http://server.com/logthis.asp?msg=Here_goes_the_commit_message类似的东西)主要的PITA是隔离正确的新修订列表,我从/ 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3109 次 |
| 最近记录: |