Git 将 SHA 作为 tup 构建二进制文件的一部分



我正在使用tup构建一个项目,并希望将当前提交的SHA包含在二进制文件中。问题是 tup 无法识别 .git 目录中的依赖项,并且在 git HEAD 更改时不会重建版本文件。

有问题的 Tupfile 包含:

: |> git rev-parse HEAD > %o |> version-file

问题如下所示:

% tup
[...]
[ tup ] [0.068s] Executing Commands...
1) [0.026s] git rev-parse HEAD > version-file                                                                                                                                                                    
[ ] 100%
% git commit --allow-empty -m "Some commit"
[master b9a0874] Some commit
% tup
[ tup ] [0.000s] Scanning filesystem...
[ tup ] [0.001s] Reading in new environment variables...
[ tup ] [0.001s] No Tupfiles to parse.
[ tup ] [0.001s] No files to delete.
[ tup ] [0.001s] No commands to execute.
[ tup ] [0.001s] Updated.

将 .git 中的任何文件添加为依赖项会导致:

tup error: You specified a path '.git/refs/heads/*' that contains a hidden filename (since it begins with a '.' character). Tup ignores these files - please remove references to it from the Tupfile.

当当前 Git 提交更改时,如何制作 tup 重建版本文件?

你看过run ./script args功能吗?你可以在你的 Tupfile 中有一个规则说run generate_git_rule.sh,在该 shell 脚本中,你可以首先使用你想要的 git 修订版更新文件,然后将其指定为实际规则的输入。

最新更新