[英]Can I use git pre-push hook only for that case when I made a new tag?
I would like to use git pre-push hook only for that cases when I added a new tag. 我仅在添加新标签时才使用git pre-push hook。 Can I somehow analyze the push for this information?
我可以以某种方式分析此信息的推送吗?
As described in the Git githooks documentation for pre-push : 如Git githooks文档中有关预推的描述 :
Information about what is to be pushed is provided on the hook's standard input with lines of the form:
在钩子的标准输入中提供了有关要推送的内容的信息,格式为:
<local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF
For instance, if the command git push origin master:foreign were run the hook would receive a line like the following:
例如,如果运行命令git push origin master:foreign,则该钩子将收到如下一行:
refs/heads/master 67890 refs/heads/foreign 12345
So when a tag is pushed there should be a line starting with refs/tags/
. 因此,当按下标签时,应该以
refs/tags/
开头的行。
Check for this and execute your hook conditionally. 检查并有条件地执行钩子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.