简体   繁体   中英

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

I'm maintaining a homebrew web-based CRM that I version-control with Subversion. What I want is to have the revision number written into a file after I do an export to the production server so that I can display it in the CRM's status page for debugging reasons.

Is there any way to do this with command-line tools?

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)

您可以使用关键字替换使信息始终存在于文件中。

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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