問題描述
我想讓我的 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.php
2) 在沒有安裝 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 版本號?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!