导出后如何将当前修订号保存到文件中? [英] How to get the current revision number into a file after export?

查看:93
本文介绍了导出后如何将当前修订号保存到文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在维护一个基于Homebrew的基于Web的CRM,该版本可通过Subversion进行版本控制.我想要的是在导出到生产服务器后将修订号写到文件中,以便出于调试原因可以在CRM的状态页中显示它.

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?

推荐答案

从技术上讲,导出后您不确定,因为中间可能会发生另一次提交.实际上,您可以使用svn info <URL>来获取信息.当然,您可以先执行svn info,提取修订并导出该修订以确保两者都对应.

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.

如果您结帐而不是导出,则可以通过svn info <path>来获取信息.

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

另一种方法是在导出的文件之一中使用关键字(我们称其为script.h),如下所示:

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

如果将svn:keywords属性赋予文件(并提交),则$ Revision $将在结帐或导出时替换:

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

(还有其他替代,请检查 SVN文档以获取更多详细信息)

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

这篇关于导出后如何将当前修订号保存到文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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