本文介绍了维护并自动更新包含当前修订的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写一个脚本来报告我们每个项目正在使用的基础框架的哪个版本.我试图通过在我们的框架主干中创建一个 version.txt 文件来做到这一点,该文件在每次提交后自动更新为当前修订版本.这样每个拥有此基础框架副本的项目都知道它正在使用它的修订版.

I'm currently writing a script to report which revision of the base framework each of our projects are using. I'm trying to do this by creating a version.txt file in our framework trunk which gets automatically updated with the current revision after each commit. This is so each project that has a copy of this base framework know it's revision that it is using.

我遇到的问题是在每次提交后获取 version.txt 以更新修订版.

The problem i'm having is getting the version.txt to get updated with the revision after every commit.

我已经尝试使用 $Revision$ 关键字替换,但这只会在 version.txt 本身被修改时更新(这违背了目的).

I've tried using $Revision$ keyword substitution, but this will only update if version.txt is modified itself (which defeats the purpose).

我考虑过使用预提交钩子对 version.txt 进行更改,以便将其添加到要提交的文件列表中,但不确定如何在预提交期间将文件添加到提交列表中.

I've thought about using a pre-commit hook to make a change to version.txt so it gets added to the list of files to commit but not sure how to add a file to the commit list during a pre-commit.

有没有更好的方法来解决这个问题?

Any better ways to go about this?

谢谢

推荐答案

  1. 您不能也不能在预提交挂钩中更改交易内容
  2. 您仍然可以在 version.txt 中使用关键字并在提交后钩子的附加提交中修改+提交(钩子将获得相当奇特的逻辑,但它会起作用),以中毒"存储库的成本为 2 倍的提交(1 个数据 + 1 个控制)
  3. 你仍然可以在version.txt中使用关键字并使用single commit,如果你在每次提交之前加入变更列表中提交文件和version.txt所需的

  1. You must not and can not change content of transaction in pre-commit hook
  2. You still can use keyword in version.txt and modify+commit in additional commit from post-commit hook (hook will get rather exotic logic, but it will work) for the cost of "poisoning" repository by 2x amount of commits (1 data + 1 control)
  3. You still can use keyword in version.txt and use single commit, if you before every commit join needed for commit files and version.txt in changelist

  • 如果您的项目在开发阶段也被版本化为框架(以及与外部链接的框架),您始终可以在项目的 WC 内框架的嵌套 WC 中检查 svn:external 属性或 svn info
  • 如果您想知道已部署项目中框架的版本,您可以在 deploy-process 创建 version.txt 并在可部署树中包含所需内容,阅读 SubWCRev(TortoiseSVN 的一部分)或 Linux 等效的 SVNRev

这篇关于维护并自动更新包含当前修订的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 22:30