Last active
August 29, 2015 14:09
-
-
Save sayedihashimi/d5c38257058edfab292a to your computer and use it in GitHub Desktop.
PowerShell function that can report the contributiors of a git repo on disk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
This can be used to get a list of the contributors for a git repo (folder). | |
Inspired by http://ayende.com/blog/4532/extracting-a-list-of-committers-from-git. | |
.EXAMPLE | |
Get-ChildItem .\ -Directory -Exclude .git | Get-Contributors -verbose| select -unique -verbose|sort | |
#> | |
function Get-Contributors{ | |
[cmdletbinding()] | |
param( | |
[Parameter(Mandatory=$true,Position=0,ValueFromPipeline=$true)] | |
[string[]]$gitfolders | |
) | |
process{ | |
foreach($gitfolder in $gitfolders){ | |
'start on folder [{0}]' -f $gitfolder | Write-Verbose | |
Push-Location | |
Set-Location $gitfolder | |
# get latest to ensure the most up to date list | |
'git pull' | Write-Verbose | |
&git pull | Out-Null | |
'git log --raw' | Write-Verbose | |
$authors = (git log --raw | | |
Where-Object {$_.StartsWith("Author:")} | | |
% {$_.TrimStart("Author: ") -replace '\s<\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b.',''} | | |
Select-Object -Unique) | |
"authors:`n[{0}]" -f ($authors -join "`n" ) | Write-Verbose | |
$authors | |
Pop-Location | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment