制作新标签时,只能在这种情况下使用git pre-push hook吗? [英] Can I use git pre-push hook only for that case when I made a new tag?
问题描述
我仅在添加新标签的情况下才使用git pre-push hook.我可以以某种方式分析此信息的推动力吗?
I would like to use git pre-push hook only for that cases when I added a new tag. Can I somehow analyze the push for this information?
推荐答案
如Git中所述 githooks 文档,用于预推:
As described in the Git githooks documentation for pre-push:
钩子的标准输入上提供了有关要推送的内容的信息,格式为:
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
例如,如果运行了git push origin master:foreign命令,则该钩子将收到以下内容:
For instance, if the command git push origin master:foreign were run the hook would receive a line like the following:
refs/heads/master 67890 refs/heads/foreign 12345
因此,当按下标签时,应该以refs/tags/
开头的行.
So when a tag is pushed there should be a line starting with refs/tags/
.
对此进行检查并有条件地执行钩子.
Check for this and execute your hook conditionally.
这篇关于制作新标签时,只能在这种情况下使用git pre-push hook吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!