简体   繁体   English

使用 Subversion 构建 PHP 项目的生产版本

[英]Making a production build of a PHP project with Subversion

If you are working in PHP (or I guess any programming language) and using subversion as your source control, is there a way to take your project (for example):如果您正在使用 PHP(或者我猜是任何编程语言)并使用颠覆作为您的源代码控制,有没有办法让您的项目(例如):

C:\Projects\test\.svn C:\Projects\test\.svn
C:\Projects\test\docs\ C:\Projects\test\docs\
C:\Projects\test\faq.php C:\Projects\test\faq.php
C:\Projects\test\guestbook.php C:\Projects\test\guestbook.php
C:\Projects\test\index.php C:\Projects\test\index.php
C:\Projects\test\test.php C:\Projects\test\test.php

and build/copy/whatever it so it weeds out certain files and becomes:并构建/复制/不管它,所以它会清除某些文件并变成:

C:\Projects\test\faq.php C:\Projects\test\faq.php
C:\Projects\test\guestbook.php C:\Projects\test\guestbook.php
C:\Projects\test\index.php C:\Projects\test\index.php

automatically?自动地? I'm getting tired of making a branch, and then going through the branch and deleting all of the ".svn" folders, the docs directory, and my prototyping files.我已经厌倦了创建一个分支,然后遍历分支并删除所有“.svn”文件夹、docs 目录和我的原型文件。

I know I could probably use a.bat file to only copy the specific files I want, but I was hoping there was some way with subversion to sort of pseudo ignore a file, to where it will still version it, but where you could make a snapshot of the project that ignores the files you told it to pseudo ignore.我知道我可能可以使用 a.bat 文件来仅复制我想要的特定文件,但我希望有某种方式可以使用 subversion 来伪忽略文件,它仍然会对其进行版本化,但你可以在哪里制作忽略您告诉它伪忽略的文件的项目快照。

I know I read online somewhere about some functionality that at least lets you copy without the.svn folders, but I can't find it now.我知道我在网上某处读到了一些功能,这些功能至少可以让您在没有 .svn 文件夹的情况下进行复制,但我现在找不到。

If you use TortoiseSVN, you can use the export feature to automatically strip out all of the.svn files.如果您使用 TortoiseSVN,您可以使用导出功能自动剥离所有 .svn 文件。 I think other svn things have the same feature.我认为其他 svn 东西具有相同的功能。

Right click the root project folder, then select TortoiseSVN > Export , and tell it where you want the .svn free directory.右键单击根项目文件夹,然后 select TortoiseSVN > Export ,并告诉它您想要.svn自由目录的位置。

Copy all the files manually or using your existing method for the first time.手动复制所有文件或首次使用现有方法。 Then, since I take it you're on a Windows platform, install SyncToy and configure it in the subscribe method , which would effectively one-way copy only the changes made since the last pseudo-commit to production for files already in production.然后,因为我认为你在 Windows 平台上,安装SyncToy并在subscribe 方法中配置它,这将有效地单向复制自上次伪提交到生产中已在生产中的文件以来所做的更改。 If you want to add a file you can just copy it manually and resume the SyncToy operation.如果您想添加一个文件,您可以手动复制它并恢复 SyncToy 操作。

Ok, so my final solution is this:好的,所以我的最终解决方案是:

Use the export command to export to a folder called "export" in the same directory as a file called "deploy.bat", then I run the deploy script (v1 stands for version 1, which is what version I am currently on in this project) This script utilizes 7-Zip, which I have placed on my system path so I can use it as a command line utility:使用导出命令导出到与名为“deploy.bat”的文件位于同一目录中的名为“export”的文件夹,然后我运行部署脚本(v1 代表版本 1,这是我目前在此使用的版本项目)此脚本使用 7-Zip,我已将其放在系统路径中,因此我可以将其用作命令行实用程序:

rem replace the v1 directory with the export directory
rd /s /q v1
move /y export\newIMS v1
rd /s /q export

rem remove the prepDocs directory from the project
rd /s /q v1\prepDocs

rem remove the scripts directory from the project
rd /s /q v1\scripts

rem remove individual files from project
del v1\.project
rem del v1\inc\testLoad.html
rem del v1\inc\testInc.js

SET /P version=Please enter version number:

rem zip the file up with 7-Zip and name it after whatever version number the user typed in.
7z a -r v%version%.zip v1

rem copy everything to the shared space ready for deployment
xcopy v%version%.zip /s /q /y /i "Z:\IT\IT Security\IT Projects\IMS\v%version%.zip"
xcopy v1 /s /q /y /i "Z:\IT\IT Security\IT Projects\IMS\currentVersion"

rem keep the window open until user presses any key
PAUSE

I didn't have time to check out the SyncToy solution, so don't take this as me rejecting that method.我没有时间查看 SyncToy 解决方案,所以不要认为这是我拒绝该方法。 I just knew how to do this, and didn't have time to check that one out (under a time crunch right now).我只知道如何做到这一点,并且没有时间检查那个(现在在时间紧迫的情况下)。

Sources:资料来源:

http://commandwindows.com/command2.htm http://commandwindows.com/command2.htm
http://www.ss64.com/nt/ http://www.ss64.com/nt/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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