在“export-subst”文件中添加标记

时间:2013-10-29 13:46:20

标签: git

场合

我们有一个git工作流,其中所有发布版本都堆叠在master分支上,当提交准备好部署时,我们为其添加一个标记,然后使用git archive构建一个要部署的捆绑包。

我们使用version.txt标记的.gitattributes文件,其中包含选项export-subst,以跟踪用于构建给定存档的提交。

问题

如果我在$Format:%d$中编写version.txt并导出标记的提交,我会在结果文件中写入(HEAD, tag, master)之类的内容。

如何单独使用tag

[edit]有一个git命令已经产生了:

git describe --tags HEAD

这将输出:

latest_tag            #if HEAD is tagged

latest_tag-5-g03cc91b #if HEAD is not tagged,
                      #and the latest tag is 5 commits ago on commit g03cc91b

有没有办法在version.txt中用这个输出替换一个slug?

1 个答案:

答案 0 :(得分:3)

您可以使用content filter driver git checkout会自动执行您想要的确切更改。

content filter river: smudge

(来自Pro Git book 7.2 Customizing Git - Git Attributes

您在.gitattributes file smudge脚本中声明,该脚本将替换特殊标记(您希望替换为git describe --tags HEAD),而不会触及其他标记由export-subst上的git archive修改。

然后你打电话给git archive,应该(未经测试)替换其余部分。

相关问题