所以下面让我在文件列表上做一些事情:
$stuff = Get-ChildItem .* -recurse -include ('*.txt', '*.doc')
foreach ($s in $stuff){
Write-Host $s
}
但是,我希望$stuff
是我的回购的结果,告诉我哪些文件已更改
HG 统计 -m *.txt *.doc
但是此命令返回类似以下内容:
M foo.txt
M bar.doc
当我真正需要的是:
.foo.txt
.bar.doc
您需要
解析 hg
的输出。 AFAIK,没有本机功能。 以下代码将捕获您的更改:
# |?{$_} ignores empty splits
$changes = (hg stat -m *.txt *.doc) -split 'Ms' | Where-Object { $_ }
Get-ChildItem -Recurse -Include @('*.txt','*.doc') |
Where-Object { $changes -contains $_.Name }