我目前正在尝试编写一个小的powershell脚本(我没有Powershell脚本编写的经验,所以我想用它作为测试),它循环遍历我们的svn存储库,并使用注释"Reviewed by;No-one“计算提交了多少次,因为这表示未审查的提交。
我目前有以下内容
$repositorys = @("Path1", "path2","path3","path4")
$matches = 0
foreach ($path in $repositorys){
"Path: {0}" -f $path.tostring()
( [xml] (svn log --xml $path)).log.logentry | Where-Object {$_.msg -imatch "(Reviewed By: (no(.*)one))" } | measure-object | format-list
}这给出了输出,其中的计数取决于它找到的匹配项的数量
Count Average Sum Maximum Minimum Property
----- ------- --- ------- ------- --------
1如果我删除了度量对象,那么我将获得SVN提交的详细信息(版本、作者、消息、日期等)。
本质上,我希望能够报告的是未审核提交的数量和详细信息(因此,本质上是上述两种方法之间的合并)。所以我的报告看起来像是
Path1:
Number of un-reviewed commits: xx
Revision Author
-------- -------
x x有人能开导我吗??这个是可能的吗?
发布于 2009-07-20 17:07:05
这就是 cmdlet的用途。
[xml] (svn log --xml $path)).log.logentry |
? {$_.msg -imatch "(Reviewed By: (no(.*)one))" } |
tee -variable temp |
measure |
% { "Number of un-reviewed commits: $($_.count)" }
$temp | fl这里没有什么是你不能通过手动分解管道和赋值变量来做的,但是"tee“是一个很方便的捷径。
它的另一个常见用途是将中间结果写入文件。有关详细信息,请参阅“帮助tee -examples”。
发布于 2009-07-20 11:23:44
在这种情况下,你必须输出两个不同的东西。我建议您将执行此工作的管道的结果保存在一个变量中,然后执行以下操作:
$x = ( [xml] (svn log --xml $path)).log.logentry | Where-Object {$_.msg -imatch "(Reviewed By: (no(.*)one))" }
Write-Host Number of un-reviewed commits: ($x.Count)
$x | fl因此,您只需输出数字,然后从流水线中丢弃您的集合以打印它。
https://stackoverflow.com/questions/1152719
复制相似问题