我目前正在尝试编写一个小的PowerShell脚本(我没有使用Powershell脚本的经验,因此希望将其用作测试),它循环遍历我们的svn存储库,计算已经通过评论"已审核;否"进行了多少次提交-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
}
Run Code Online (Sandbox Code Playgroud)
这给了我带有计数的输出,具体取决于它找到的匹配数量
Count Average Sum Maximum Minimum Property
----- ------- --- ------- ------- --------
1
Run Code Online (Sandbox Code Playgroud)
如果我删除了measure-object,那么我将获得SVN提交的详细信息(修订版,作者,消息,日期等)
基本上我想要报告的是未经审核的提交的数量和细节(所以基本上是上述两种方法之间的合并).所以我的报告看起来像
路径1:
Number of un-reviewed commits: xx
Revision Author
-------- -------
x x
Run Code Online (Sandbox Code Playgroud)
谁能开导我?这可能吗?
这就是Tee-Object 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
Run Code Online (Sandbox Code Playgroud)
通过手动分解管道和分配变量,你无法做到这一点,但"tee"是一个方便的快捷方式.
它的另一个常见用途是将中间结果写入文件.有关详细信息,请参阅"help tee -examples".
归档时间: |
|
查看次数: |
5719 次 |
最近记录: |