我想让我的PHP应用程序标有使用的版本号,但我不想使用 CruiseControl 或更新文件并每次上传.我该怎么办?
I want to have my PHP application labeled with the revision number which it uses, but I don't want to use CruiseControl or update a file and upload it every time. How should I do it?
推荐答案SVN关键字不是一个好的解决方案.正如其他人指出的那样,在文件中添加$ Revision $仅会影响特定文件,该文件可能不会长期更改.
SVN keywords is not a good solution. As others pointed out adding $Revision$ in a file only affects the specific file, which may not change for a long time.
记住在每次提交都没有意义之前编辑"文件(通过添加或删除空白行).您也可以手动输入修订.
Remembering to "edit" a file (by adding or removing a blank line) before every commit is pointless. You could as well just type the revision by hand.
(我知道)实现此目标的一种好方法是拥有一个自动化的部署过程(这总是一件好事)并使用命令svnversion.这是我的工作:
One good way to do it (that I know of) is to have an automated deployment process (which is always a good thing) and using the command svnversion. Here is what I do:
我需要修订的地方都包括:<?php include 'version.php'; ?>.此"version.php"文件仅具有修订号.此外,它不是存储库的一部分(将被忽略).这是我的创建方式:
Wherever I need the revision I do an include: <?php include 'version.php'; ?>. This "version.php" file only has the revision number. Moreover it is not part of the repository (it set to be ignored). Here is how I create it:
1)在服务器上安装了SVN的项目上,我也将其用于部署.将最新版本获取到服务器上我有一个脚本,该脚本除其他功能外还可以执行以下操作(该脚本在服务器上运行):
1) On projects where SVN is installed on the server, I also use it for deployment. Getting the latest version to the server I have a script that among other things does the following (it runs on the server):
cd /var/www/project svn update rm version.php svnversion > version.php2)在未安装SVN的项目中,我的部署脚本更加复杂:它在本地创建version.php文件,压缩代码,然后上载和提取
2) On projects where SVN is not installed my deployment script is more complex: it creates the version.php file locally, zips the code, uploads and extracts it
更多推荐
如何获得PHP中的Subversion版本号?
发布评论