且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

仅在添加新标签后才在接收后触发某些内容

更新时间:2023-12-03 13:11:22

post-receive挂钩接收stdin上有关在该操作中更新的所有ref(分支,标签等)的信息.每行具有以下格式,摘自 githooks联机帮助页:

The post-receive hook receives information on stdin about all the refs (branches, tags, ...) that were updated in that operation. Each line has the following format, taken from the githooks manpage:

<old-value> SP <new-value> SP <ref-name> LF

这将是创建新标签的示例:

So this would be an example of a new tag being created:

0000000000000000000000000000000000000000 0123456789abcdef0123456789abcdef01234567 refs/tags/mytag

您只需要阅读stdin并检查行是否与此格式匹配.基本上,第一个单词"全为零,第三个单词以refs/tags/开头.

You simply need to read from stdin and check whether a line matches this format. Basically the first "word" is all zeroes and the third word starts with refs/tags/.