【问题标题】:git post-receive hook and prevent tags pushinggit post-receive 钩子并防止标签推送
【发布时间】:2011-11-23 14:13:44
【问题描述】:

在我的 GIT 的 post-receive 挂钩中,如果推送标签,我需要避免执行某些代码。

我尝试使用环境变量 $refname 但它看起来是空的。

有什么想法吗?

谢谢

随机化

【问题讨论】:

    标签: git git-post-receive


    【解决方案1】:

    Post 接收钩子得到类似

    refs/tag/FOO 在标签的情况下和 refs/heads/branch-foo 在分支的情况下

    基于标签与您可以确定的分支。

    【讨论】:

      【解决方案2】:

      $rev_type - 你从哪里得到这样一个可用的环境变量的想法?

      post-receive 钩子从它的标准输入获取输入,格式如下:

      <oldrev> <newrev> <refname>
      

      从标准输入读取 refname 并查看它是否包含标签(类似于refs/tags/&lt;tagname&gt;

      参考这里:http://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

      【讨论】:

      • 抱歉打错了。我正在使用“refname”,但它是空的。可能是我试图从标准输入读取它的方式:read refname; refname=$(读取 refname); refname=读取参考名;等等
      猜你喜欢
      • 2011-04-15
      • 2013-02-02
      • 1970-01-01
      • 2014-05-13
      • 2014-10-28
      • 1970-01-01
      • 2015-08-10
      • 2012-02-17
      • 1970-01-01
      相关资源
      最近更新 更多