gpt4 book ai didi

git - 在 "export-subst"文件中添加标签

转载 作者:太空狗 更新时间:2023-10-29 13:41:12 24 4
gpt4 key购买 nike

情况

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

我们使用一个 version.txt 文件,在 .gitattributes 中用 export-subst 选项标记,来跟踪哪个提交是用于构建给定的存档。

问题

如果我在 version.txt 中编写 $Format:%d$,并导出一个标记的提交,我将得到类似 (HEAD, tag, master) 写入结果文件。

我怎样才能单独使用标签

[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 吗?

最佳答案

你可以使用 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-substgit archive 上。

然后你调用git archive ,应该(未测试)替换其余部分。

关于git - 在 "export-subst"文件中添加标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19659976/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com