如何为每个已提交此文件的提交更新未修改文件中的修订号?

发布于 2024-09-17 18:20:59 字数 522 浏览 8 评论 0原文

我的 SVN 项目中有一个 revision.txt 文件。

基本上,我希望当我使用提交后工作副本将具有的修订号调用 svn ci 时,该文件会自动更新。

例如:

  1. revision.txt 包含“10”
  2. 我对我的工作副本(其他文件,而不是 revision.txt)进行了一些更改
  3. svn ci
    • 启动钩子脚本
    • 阅读下一个版本号
    • 更新 revision.txt
    • 提交更改(还有 revision.txt)
  4. 现在revision.txt已经提交,修订号为11

我尝试使用钩子脚本但没有成功。我无法在提交之前检索下一个修订号并更新事务。

然后尝试使用“auto-props”,但它们仅适用于修改后的文件。 更好的解决方案是仅使用钩子脚本,而不使用检查修订和更新的包装器脚本。

有可能吗?欢迎举例

I have a revision.txt file in my SVN project.

Basically I want that this file is updated automatically when I call svn ci with the revision number the working copy will have after the commit.

For example:

  1. revision.txt contains "10"
  2. I make some change to my working copy (other files, not revision.txt)
  3. svn ci
    • launch hook script
    • read next revision number
    • update revision.txt
    • commit changes (also revision.txt)
  4. now revision.txt is already committed with revision number 11

I've tried without success with an hook script. I cannot retrieve the next revision number and update the transactione before committing.

Then try with "auto-props", but they are working only with modified files.
The preferable solution is using only hook script and not using a wrapper script which check the revision and update.

Is possible ? Examples are welcome

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

还如梦归 2024-09-24 18:20:59

由于竞争条件,您无法在提交之前猜测下一个修订号 - 您无法保证,直到事后,其他人没有在您之前进入。在 svn commit hook 中更改文件也是一种极其糟糕的形式 - 工作副本全部过时且混乱,因为它们只从服务器得到“它工作了”或“它失败了”,从来没有“它工作了,但是通过该文件现在具有这些内容的方式......”

您需要这个做什么?也许还有另一种方法可以实现您想要实现的目标。

您可以使用“svn 在需要之前自动生成 revision.txt 文件info”,并将“修订:”行过滤到文件中。

You can't guess the next revision number before commit due to race conditions - you can't guarantee, until after the fact, that someone else hasn't got in ahead of you. It's also extremely bad form to change files in a svn commit hook - working copies get all out of date and messy, as they only get a "it worked" or "it failed" from the server, never a "it worked, but by the way that file now has these contents ..."

What do you need this for? Perhaps there's another way to get what you're trying to achieve.

You could auto-generate the revision.txt file just before it's needed by using "svn info", and filtering the "Revision: " line into the file.

像你 2024-09-24 18:20:59

正如您已经提到的,基于 svn:keywords 只能更改已修改的文件。但我认为您需要的是一个处理此类信息的构建系统(可能是构建服务器/持续集成服务器)。

As you already mentioned based on svn:keywords it's only possible to change modified files. But i think what you need is a build system which handles such kind of information (may be a build server / continous integration server).

猛虎独行 2024-09-24 18:20:59

关键字替换最接近你想要的,但这也不起作用,因为它给你的是文件的最后修改,而不是项目的最后修改。来自关于此问题的颠覆常见问题解答:

您想要的信息(修订版
您的工作副本)可用
来自命令svnversion;它给了
您有关修订级别的信息
给定路径的工作副本(请参阅
svnversion --help 了解详细信息)。

您可以将其合并到您的构建中
或发布过程以获得
您需要的信息进入源
本身。

Keyword substitution comes closest to what you want, but that doesn't really work either because it gives you the last modification of the file, not of the project. From the subversion FAQ on this issue:

The information you want (the revision
of your working copy) is available
from the command svnversion; it gives
you information on the revision level
of a working copy given a path (see
svnversion --help for details).

You can incorporate it into your build
or release process to get the
information you need into the source
itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文