将 subversion 存储库编号写入代码 [英] Getting the subversion repository number into code

查看:24
本文介绍了将 subversion 存储库编号写入代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一种在代码中记录项目版本的方法,以便在测试时使用它并帮助跟踪错误.似乎最好使用的版本号只是来自 Subversion 的当前修订号.有没有一种简单的方法可以将这个数字挂接到(在我的例子中是 C++)头文件或其他东西中,然后我可以在代码中找到它?我猜这是一个提交后的钩子还是什么?

I'd like to implement a way of recording the version of a project within code, so that it can be used when testing and to help track bugs. It seems the best version number to use would just be the current revision number from Subversion. Is there an easy way to hook this number into a (C++ in my case) header file or something, which I can then get at in code? I guess this is a post commit hook or something?

有没有人有任何实现这个的经验(请分享代码?),或者可以提出更好的替代方案?谢谢.

Does anyone have any experience of implementing this (with code to share, please?), or can suggest a better alternative? Thanks.

推荐答案

虽然很漂亮,但修订版关键字技巧只会在该修订版中更改文件时更新文件 - 如果您不更改文件,那么它将继续反映旧版本.

While nifty, the revision keyword trick only updates the file when it's changed in that revision - if you don't change the file, then it will continue to reflect the old revision.

如果您希望软件始终反映整体修订号,那么您必须深入研究相关的SVN条目文件并解压出来,这不是太难(是一个XML文件).

If you want the software to always reflect the overall revision number, then you'll have to delve into the relevant SVN entries file and extract it, which isn't too difficult (it's an XML file).

维基百科在他们的版本页面上执行此操作以指示正在运行的软件的修订版居住;代码在这里 - 寻找getSvnRevision() 方法.

Wikipedia does this on their version page to indicate the revision of the software that's running live; the code is here - look for the getSvnRevision() method.

这篇关于将 subversion 存储库编号写入代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆