想要 git post receive hook 进行新的提交和推送
我希望我的接收后挂钩负责更新存储库中的版本文件 本身,在一定条件下。所以,假设我的存储库中有一个文件 version.txt, 我希望 post receive 钩子能够更新 version.txt 中的版本字符串。
这意味着再次推动回购。这可能吗?
谢谢!
I would like my post-receive hook to be responsible for updating a version file in the repo
itself, under certain conditions. So, suppose I have a file version.txt in my repository,
I would like the post receive hook to update a version string inside version.txt.
That would mean another push to the repo. Is this possible?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在服务器上拥有存储库的工作目录。在接收后,git pull 到工作目录,根据需要更新 version.txt 并提交和推送。这将再次触发 post-receive,所以要小心你如何进行条件更新,否则会进入一个循环。
You can have a working directory of your repo on your server. In the post-receive, git pull on the working directory, update the version.txt as needed and commit and push. This will trigger the post-receive one more time, so be careful about how you are doing your conditional update, otherwise it will go into a cycle.
我不想尝试进行任何进一步的提交/推送,而是使用 按顺序过滤驱动程序,在签出/更新时能够为该
version.txt
文件生成正确的内容(即内部包含正确的版本字符串)smudge
脚本(如果它能够识别 < 的内容) code>version.txt 文件(即 不会的名称/路径所说的文件作为参数),将用正确的信息替换该文件的模板部分。I would rather not try to make any further commit/push, but use a filter driver in order, on checkout/update to be able to generate the right content for that
version.txt
file (i.e. with the right version string inside)The
smudge
script, if it is able to recognized the content of aversion.txt
file (i.e. it won't have the name/path of said file as parameter), would replace a template section of that file with the right information.