简体   繁体   English

Subversion - 将版本号放在一个文件中

[英]Subversion - put version number in a file

I just want a single file, called "revision", which contains the repository revision number at any given time so that when I export my repository, my application is able to see which revision it was. 我只想要一个名为“revision”的文件,它包含任何给定时间的存储库修订号,这样当我导出我的存储库时,我的应用程序就可以看到它是哪个版本。

How can I do this? 我怎样才能做到这一点?

The problem with using normal Keyword Substitution is that $rev$ only shows the last revision in which that file changed. 使用普通关键字替换的问题是$rev$仅显示该文件更改的最后一个修订版。 I haven't tried it myself, but there is a tool called svnversion that comes with SVN that I believe you can use to get the revision number of the working copy. 我自己没有尝试过,但是SVN附带了一个名为svnversion的工具,我相信你可以使用它来获取工作副本的修订版号。 It's then just a case of configuring your build process to use this tool and insert the result into your revision file. 然后,只需配置构建过程即可使用此工具并将结果插入到修订文件中。

There is a good guide on how to use svnversion (especially if you're using ANT) here: http://cameronstokes.com/2009/12/12/using-svnversion-from-ant 关于如何使用svnversion (特别是如果你使用的是ANT)有一个很好的指南: http//cameronstokes.com/2009/12/12/using-svnversion-from-ant

I suppose you could do something using pre-commit hook, but I don't really know if that's such a great idea. 我想你可以使用pre-commit hook做一些事情,但我真的不知道这是不是一个好主意。

Why don't you version your app on its own? 为什么不自行编写应用程序版本? (and eg. put version number in the commit comment) Wouldn't that be a simpler solution? (例如,将版本号放在提交注释中)这不是一个更简单的解决方案吗?

What is more svn revision numbers are given one by one no matter what branch it's being committed to - is this ok for you? 什么是更多的svn修订版号一个接一个地给出,无论它承诺什么分支 - 这对你好吗?

Try checking this out. 试试这个。 We used to do this with CVS. 我们曾经用CVS做过这个。

http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM