git - git 在结帐时创建二进制文件
问题描述
我正在尝试在 上创建文件git checkout
,例如从 tex 文件创建 pdf 或从渐近线源文件创建图像。我知道我可以只签出源文件,然后手动处理它们,但我更喜欢自动完成。到目前为止,我尝试使用 smudge 过滤器,但似乎 smudge 只能修改源文件而不能创建新的二进制文件。关于如何在结帐期间从源文件创建二进制文件的任何想法?
我处理渐近线文件的不成功的涂抹过滤器。如果直接在 shell 中调用,但不能通过 git 调用,效果很好:
#!/bin/bash
cat $1
asy $1 >/dev/null
解决方案
好的,根据@torek 的评论,我设法通过创建自己的结帐后挂钩找到了一个可行的解决方案。这个钩子 (in .git/hooks/post-checkout
) 将在结帐后对所有 *.asy 文件运行渐近线。因此,它不仅在被检出的文件上运行,因此在具有许多渐近线文件的大型项目中可能会变得相当慢。但它以某种方式起作用,我希望它对其他人也有用。
#!/bin/bash
printf '\npost-checkout hook\nregenerates all asymptote files\n'
# Now find all files ending with .asy and run asymptote on them:
find . -type f -name '*.asy' -execdir asy \{\} \;
# Note that this will recompile ALL asymptote files, not only the possibly changed ones.
# This is because I have no clue on how to check what changed during checkout.
推荐阅读
- android - Android lint 导出到 HTML 不适用于大量检查结果
- regex - 如何使用 HTML5 验证日期模式
- c# - 在 iis express 中运行 asp.net core mvc 项目时遇到问题
- mysql - 如果日期不存在,则获取给定日期的最后一行
- javascript - 如果我在对话框中打开 ASP RadioButtons,服务器端 OnCheckedChanged 不起作用
- php - mpdf 生成的文件总是要求在 acrobat 中关闭之前保存更改
- python - 使用 xlsxwriter 将 Excel 中的一组单元格的边框更改为粗框边框
- oracle - Oracle:是否可以修剪字符串并计算出现次数,然后插入新表?
- c# - 遗传算法:为什么我的随机种群适应度值相同?
- angular - 部署在同一 Tomcat 服务器上的两个应用程序之间的会话共享