Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Created February 16, 2023 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewjberger/26d289ee1439b1d9dfb399086cf88502 to your computer and use it in GitHub Desktop.
Save matthewjberger/26d289ee1439b1d9dfb399086cf88502 to your computer and use it in GitHub Desktop.
Get the commit for a specific user that added more lines than all other commits
git log --shortstat --author="Matthew J. Berger" --pretty=format:"%H - %an, %ar : %s" | foreach {
if ($_ -match '([0-9a-fA-F]{40})') {
$commitHash = $matches[1]
}
if ($_ -match '(\d+)\s+insertion\S*.*(\d+)\s+deletion\S*') {
$insertions = [int]$matches[1]
$deletions = [int]$matches[2]
[pscustomobject]@{
CommitHash = $commitHash
Insertions = $insertions
Deletions = $deletions
LineCount = $insertions - $deletions
CommitInfo = $_
}
}
} | Sort-Object LineCount -Descending | Select-Object -First 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment