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 co
In PowerShell, set your location to the working copy and use this command.
svn.exe log --quiet |
? { $_ -notlike '-*' } |
% { ($_ -split ' \| ')[1] } |
Sort -Unique
The output format of svn.exe log --quiet
looks like this:
r20209 | tinkywinky | 2013-12-05 08:56:29 +0000 (Thu, 05 Dec 2013)
------------------------------------------------------------------------
r20208 | dispy | 2013-12-04 16:33:53 +0000 (Wed, 04 Dec 2013)
------------------------------------------------------------------------
r20207 | lala | 2013-12-04 16:28:15 +0000 (Wed, 04 Dec 2013)
------------------------------------------------------------------------
r20206 | po | 2013-12-04 14:34:32 +0000 (Wed, 04 Dec 2013)
------------------------------------------------------------------------
r20205 | tinkywinky | 2013-12-04 14:07:54 +0000 (Wed, 04 Dec 2013)
Filter out the horizontal rules with ? { $_ -notlike '-*' }
.
r20209 | tinkywinky | 2013-12-05 08:56:29 +0000 (Thu, 05 Dec 2013)
r20208 | dispy | 2013-12-04 16:33:53 +0000 (Wed, 04 Dec 2013)
r20207 | lala | 2013-12-04 16:28:15 +0000 (Wed, 04 Dec 2013)
r20206 | po | 2013-12-04 14:34:32 +0000 (Wed, 04 Dec 2013)
r20205 | tinkywinky | 2013-12-04 14:07:54 +0000 (Wed, 04 Dec 2013)
Split by ' \| '
to turn a record into an array.
$ 'r20209 | tinkywinky | 2013-12-05 08:56:29 +0000 (Thu, 05 Dec 2013)' -split ' \| '
r20209
tinkywinky
2013-12-05 08:56:29 +0000 (Thu, 05 Dec 2013)
The second element is the name.
Make an array of each line and select the second element with % { ($_ -split ' \| ')[1] }
.
tinkywinky
dispy
lala
po
tinkywinky
Return unique occurrences with Sort -Unique
. This sorts the output as a side effect.
dispy
lala
po
tinkywinky
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.
#!/usr/bin/env pwsh
$repos = @(
'Common/'
'Database/'
'Integration/'
'Reporting/'
'Tools/'
'Web/'
'Webservices/'
)
foreach ($repo in $repos) {
$url = "https://svn.example.com:8443/svn/$repo"
$users += ([Xml](svn log $url --xml)).log.logentry.author | Sort-Object -Unique
}
$users | Sort-Object -Unique