如何获取所有 Subversion 提交作者用户名的列表?
我正在寻找一种有效的方法来获取整个 SVN 存储库或给定资源路径的唯一提交作者列表。我还没有找到专门为此目的的 SVN 命令(并且不希望有),但我希望可能有一种比我迄今为止在终端(在 OS X 上)中尝试过的更好的方法
svn log --quiet | grep "^r" | awk '{print $3}'
svn log --quiet --xml | grep author | sed -E "s:</?author>::g"
:其中每行都会给我一个作者姓名,但它们都需要过滤掉相当多的额外信息。它们也不处理同一作者姓名的重复项,因此对于少数作者的大量提交,网络上会存在大量冗余。通常我只想查看唯一的作者用户名。 (实际上,有时可以很方便地推断每个作者的提交计数,但即使在这些情况下,如果发送聚合数据会更好。)
我通常与客户合作-only 访问,因此 svnadmin 命令不太有用,但如果有必要,如果绝对必要或更有效的话,我可能可以请求存储库管理员的特别帮助。我正在使用的存储库有数以万计的提交和许多活跃用户,我不想给任何人带来不便。
I'm looking for an efficient way to get the list of unique commit authors for an SVN repository as a whole, or for a given resource path. I haven't been able to find an SVN command specifically for this (and don't expect one) but I'm hoping there may be a better way that what I've tried so far in Terminal (on OS X):
svn log --quiet | grep "^r" | awk '{print $3}'
svn log --quiet --xml | grep author | sed -E "s:</?author>::g"
Either of these will give me one author name per line, but they both require filtering out a fair amount of extra information. They also don't handle duplicates of the same author name, so for lots of commits by few authors, there's tons of redundancy flowing over the wire. More often than not I just want to see the unique author usernames. (It actually might be handy to infer the commit count for each author on occasion, but even in these cases it would be better if the aggregated data were sent across instead.)
I'm generally working with client-only access, so svnadmin
commands are less useful, but if necessary, I might be able to ask a special favor of the repository admin if strictly necessary or much more efficient. The repositories I'm working with have tens of thousands of commits and many active users, and I don't want to inconvenience anyone.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
要过滤掉重复项,请获取输出并通过管道:
sort |唯一性。因此:
如果这是做你所要求的事情的方法,我不会感到惊讶。 Unix 工具通常期望用户使用其他工具进行奇特的处理和分析。
PS 想想看,您可以合并
grep
和awk
...PPS Per Kevin Reid...
P3.S。根据 kan,使用竖线而不是空格作为字段分隔符,以正确处理带有空格的名称(还更新了 Python 示例)...
为了提高效率,您可以使用 Perl 单行代码。我不太了解 Perl,所以我最终会用 Python 来做:
或者,如果你想要计数:
那么你会运行:
To filter out duplicates, take your output and pipe through:
sort | uniq
. Thus:I woud not be surprised if this is the way to do what you ask. Unix tools often expect the user to do fancy processing and analysis with other tools.
P.S. Come to think of it, you can merge the
grep
andawk
...P.P.S. Per Kevin Reid...
P3.S. Per kan, using the vertical bars instead of spaces as field separators, to properly handle names with spaces (also updated the Python examples)...
For more efficient, you could do a Perl one-liner. I don't know Perl that well, so I'd wind up doing it in Python:
Or, if you wanted counts:
Then you'd run:
在 PowerShell 中,将您的位置设置为工作副本并使用此命令。
svn.exe log --quiet
的输出格式如下所示:用
过滤掉水平规则? { $_ - 不像 '-*' }
。按
' \| 分割'
将记录转换为数组。第二个元素是名称。
将每一行创建一个数组,并使用
% { ($_ -split ' \| ')[1] }
选择第二个元素。使用
Sort -Unique
返回唯一出现的情况。这会将输出排序作为副作用。In PowerShell, set your location to the working copy and use this command.
The output format of
svn.exe log --quiet
looks like this:Filter out the horizontal rules with
? { $_ -notlike '-*' }
.Split by
' \| '
to turn a record into an array.The second element is the name.
Make an array of each line and select the second element with
% { ($_ -split ' \| ')[1] }
.Return unique occurrences with
Sort -Unique
. This sorts the output as a side effect.我必须在 Windows 中执行此操作,因此我使用 Super Sed 的 Windows 端口 ( http://www.pement. org/sed/ ) - 并替换了 AWK & GREP 命令:
这使用可能并非所有计算机上都存在的窗口“排序”。
I had to do this in Windows, so I used the Windows port of Super Sed ( http://www.pement.org/sed/ ) - and replaced the AWK & GREP commands:
This uses windows "sort" that might not be present on all machines.
您可以使用一个远程存储库:
One a remote repository you can use:
该命令具有额外的
grep '|'
来消除错误值。否则,将包含以
'r'
开头的随机提交,从而返回提交消息中的单词。This command has the additional
grep '|'
that eliminates false values.Otherwise, Random commits starting with
'r'
get included and thus words from commit messages get returned.Powershell 支持 XML,无需解析字符串输出。
这是我在 Mac 上使用的一个快速脚本,用于跨多个存储库获取唯一的用户列表。
Powershell has support for XML which eliminates the need for parsing string output.
Here's a quick script I used on a mac to get a unique list of users across multiple repositories.
Windows 10的解决方案。
printAllAuthor.bat
sort
命令运行bat文件PS:
A solution for windows 10.
printAllAuthor.bat
sort
commandPS:
一个更简单的替代方案:
A simpler alternative: