Easy way to embed svn revision number in page in PHP?

不问归期 提交于 2019-12-05 08:23:10

You can use the svnversion CLI utility to get a more specific look at the revision, including the highest number. You could then use regular expressions to parse this.

Subversion has no concept of a global revision; rather, you'd have to recursively look through the working copy to find the highest revision number. svnversion does that for you.

The keyword subsitution method isn't reliable because it will provide the revision of the file rather than the whole codebase that you're deploying, which I presume is what you're after.

Typically I use ANT to deploy from subversion, and in the build script I'd use the replace task to substitue a revision token in a layout template or common header file with the revision number of the codebase that I'm deploying - see below. Although if anyone has a better method I'd love to hear it!

 <svn username="${svn.username}" password="${svn.password}" javaHL="${svn.javahl}">      
   <status path="${dir.build}" revisionProperty="svn.status.revision" />
 </svn>

 <replace dir="${dir.build}" token="%revision%" value="${svn.status.revision}">
   <include name="**/*.php" />
 </replace>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!