使用Subversion进行PHP项目的生产构建

时间:2020-03-05 18:38:35  来源:igfitidea点击:

如果我们使用的是PHP(或者我猜是任何一种编程语言),都使用subversion作为源代码控制,那么是否可以采用项目(例如):

C:\Projects\test\.svn

  C:\Projects\test\docs\

  C:\Projects\test\faq.php

  C:\Projects\test\guestbook.php

  C:\Projects\test\index.php

  C:\Projects\test\test.php

并构建/复制/以其他方式删除所有文件,并变成:

C:\Projects\test\faq.php

  C:\Projects\test\guestbook.php

  C:\Projects\test\index.php

自动地?我已经厌倦了创建分支,然后遍历分支并删除所有" .svn"文件夹,docs目录和原型文件。

我知道我可能可以使用.bat文件仅复制所需的特定文件,但是我希望通过某种方式进行Subversion伪忽略文件,将其仍旧版本化,但可以在哪里进行创建该项目的快照将忽略我们告知其伪文件忽略的文件。

我知道我在网上读过一些功能,至少可以让我们在没有.svn文件夹的情况下进行复制,但是现在找不到。

解决方案

回答

这是一个古怪的口香糖的想法:

手动或者首次使用现有方法复制所有文件。然后,由于我认为我们使用的是Windows平台,因此请安装SyncToy并在subscription方法中对其进行配置,该方法将有效地仅单向复制自上次将虚拟提交到生产中以来对生产中的文件所做的更改。如果要添加文件,则可以手动将其复制并继续SyncToy操作。

回答

如果使用TortoiseSVN,则可以使用导出功能自动删除所有.svn文件。我认为其他svn事物具有相同的功能。

右键单击根项目文件夹,TortoiseSVN>导出,并告诉它我们想要.svn免费目录的位置。

回答

好的,所以我的最终解决方案是:

使用export命令将文件导出到与名为" 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

我没有时间检查SyncToy解决方案,所以当我拒绝该方法时,请不要以为是。我只是知道如何执行此操作,并且没有时间(现在正处于时间紧缩的情况下)检查一下。

资料来源:

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