How to get the current revision number into a file after export?

孤街浪徒 提交于 2019-12-06 16:46:13

Technically, you can't be sure after doing the export, because another commit might have happened just in-between. Practically, you can get the information with svn info <URL>. You could of course do the svn info first, extract the revision and export that revision to make sure both correspond.

If you do a checkout instead of an export, the information is available through svn info <path>.

Another way to do that is to use keywords in one of your exported file (let's call it script.h), like this:

#define VERSION_STRING  "r$Revision$"
// ... rest of the file

If you give the svn:keywords property to your file (and commit it), the $Revision$ will be substituted at checkout or export:

svn propset svn:keywords "Revision" script.h

(there are other substitutions, check the SVN documentation for further details)

You can use keyword substitution to always have the information present in a file.

If you use Ant as your build tool, you can write a custom Ant task to grab the information from a remove Subversion server, store them into the Ant project's properties and use substitution to place these values into some properties/class.

Since you're certainly building you production application from a Subversion tags, you will not have the risk to display a wrong information (like RegGlyph mentioned)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!