所以以下内容将让我对文件列表做一些事情:
$stuff = Get-ChildItem .\* -recurse -include ('*.txt', '*.doc')
foreach ($s in $stuff){
Write-Host $s
}
但是,我希望$stuff
成为我的回购告诉我哪些文件已更改的结果
hg stat -m * .txt * .doc
但是这个命令返回的内容如下:
M foo.txt
M bar.doc
当我真正需要的是:
.\foo.txt
.\bar.doc
答案 0 :(得分:0)
您需要解析hg
的输出。 AFAIK,没有原生功能。以下代码将捕获您的更改:
# |?{$_} ignores empty splits
$changes = (hg stat -m *.txt *.doc) -split 'M\s' | Where-Object { $_ }
Get-ChildItem -Recurse -Include @('*.txt','*.doc') |
Where-Object { $changes -contains $_.Name }