使用 powershell 和 svn 删除未版本控制的文件 [英] Using powershell and svn to delete unversioned files

查看:55
本文介绍了使用 powershell 和 svn 删除未版本控制的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个构建脚本来使用 Powershell 签出代码.我需要能够用 SVN 存储库中的适当更改替换对工作副本所做的任何修改.这还包括删除在存储库中删除但未在工作副本中删除的所有文件.

I'm trying to write a build script to checkout code using Powershell. I need to be able to replace any modifications which were made to the working copy with the appropriate changes from the SVN repo. That also includes deleting any files which were deleted in the repo but not deleted in the working copy.

不幸的是,我无法进行干净的检出,因为每次运行构建脚本时检出所有 10GB 的代码效率很低.我该怎么做?

Unfortunately I cannot do a clean checkout, since it would be to inefficient to check out all 10GB of code every time the build script is run. How would I do this?

我一直在尝试以下方法:

I've been trying something along these lines:

&$SVN_EXE revert $workingPath
&$SVN_EXE update $workingPath
$x = &$SVN_EXE status $localPath --no-ignore |  where {$_ -match "^[\?I]"} | %{$_ -replace "^[\?I]",""} # get the status, get any items with a ? and strip them out
$x | %{$_ -replace "[`n]",", "} # Replace newlines with commas
Remove-Item $x # Remove all the unversioned items

我似乎无法将第 3 行的输出存储到 $x 中,而且我不太确定其余部分是否是这样做的.

I cannot seem to store the output of line #3 into $x, and I'm not quite sure if the rest of it is the way to do it.

我不确定这是否是正确的方法,但如果是,我似乎无法存储和解析来自 SVN 状态的输出.

I'm not sure if this is the proper way to go, but if it is, I cannot seem to store and parse the output from SVN status.

有人有什么建议吗?谢谢!

Does anyone have any suggestions? Thanks!

推荐答案

如果您想从工作目录中删除未跟踪和忽略的文件,请尝试以下操作:

If you want to remove untracked and ignored files from your working directory, try something like this:

svn st --no-ignore | %{ if($_ -match '^[?I]\s+(.+)'){ $matches[1]} } | rm -whatif

一旦你确认它正在做你想要它做的事情,就删除它.

Remove the -whatif once you have confirmed that it is doing what you want it to do.

这篇关于使用 powershell 和 svn 删除未版本控制的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆