feat(git-control): show commit author in branch compare, add by-user summary
Made-with: Cursor
This commit is contained in:
@@ -26,7 +26,7 @@ if (-not $ApiToken -and (Test-Path $ConfigPath)) {
|
||||
|
||||
function Get-GitLog {
|
||||
param([string]$Path, [string]$Range, [string]$Since)
|
||||
$gitArgs = @("log", $Range, "--oneline", "--no-merges")
|
||||
$gitArgs = @("log", $Range, "--no-merges", "--format=%h | %an | %s")
|
||||
if ($Since) { $gitArgs += "--since=$Since" }
|
||||
$out = & git -C $Path $gitArgs 2>&1
|
||||
if ($out) { $out } else { @() }
|
||||
@@ -65,6 +65,13 @@ function Compare-Local {
|
||||
Write-Host " Total: $($inBaseNotHead.Count) commits" -ForegroundColor Gray
|
||||
}
|
||||
if ($inHeadNotBase.Count -gt 0) {
|
||||
$byUser = $inHeadNotBase | ForEach-Object {
|
||||
$parts = $_ -split '\s*\|\s*'
|
||||
if ($parts.Count -ge 2) { $parts[1].Trim() }
|
||||
} | Where-Object { $_ } | Group-Object | Sort-Object Count -Descending
|
||||
Write-Host ""
|
||||
Write-Host "By user (unmerged):" -ForegroundColor Yellow
|
||||
$byUser | ForEach-Object { Write-Host " $($_.Name): $($_.Count) commits" }
|
||||
Write-Host ""
|
||||
Write-Host "ACTION: Merge ${HeadBranch} into ${BaseBranch} to sync hotfixes." -ForegroundColor Red
|
||||
}
|
||||
@@ -86,7 +93,11 @@ function Compare-API {
|
||||
if ($commits.Count -eq 0) {
|
||||
Write-Host " (none)" -ForegroundColor Green
|
||||
} else {
|
||||
$commits | ForEach-Object { Write-Host " $($_.sha.Substring(0,7)) $($_.commit.message.Split("`n")[0])" }
|
||||
$commits | ForEach-Object {
|
||||
$author = $_.commit.author.name
|
||||
if ($_.author.login) { $author = $_.author.login }
|
||||
Write-Host " $($_.sha.Substring(0,7)) | $author | $($_.commit.message.Split("`n")[0])"
|
||||
}
|
||||
Write-Host " Total: $($commits.Count) commits" -ForegroundColor Yellow
|
||||
}
|
||||
Write-Host ""
|
||||
@@ -97,10 +108,20 @@ function Compare-API {
|
||||
if ($commitsRev.Count -eq 0) {
|
||||
Write-Host " (none)" -ForegroundColor Gray
|
||||
} else {
|
||||
$commitsRev | ForEach-Object { Write-Host " $($_.sha.Substring(0,7)) $($_.commit.message.Split("`n")[0])" }
|
||||
$commitsRev | ForEach-Object {
|
||||
$author = $_.commit.author.name
|
||||
if ($_.author.login) { $author = $_.author.login }
|
||||
Write-Host " $($_.sha.Substring(0,7)) | $author | $($_.commit.message.Split("`n")[0])"
|
||||
}
|
||||
Write-Host " Total: $($commitsRev.Count) commits" -ForegroundColor Gray
|
||||
}
|
||||
if ($commits.Count -gt 0) {
|
||||
$byUser = $commits | ForEach-Object {
|
||||
if ($_.author.login) { $_.author.login } else { $_.commit.author.name }
|
||||
} | Group-Object | Sort-Object Count -Descending
|
||||
Write-Host ""
|
||||
Write-Host "By user (unmerged):" -ForegroundColor Yellow
|
||||
$byUser | ForEach-Object { Write-Host " $($_.Name): $($_.Count) commits" }
|
||||
Write-Host ""
|
||||
Write-Host "ACTION: Merge ${HeadBranch} into ${BaseBranch} to sync hotfixes." -ForegroundColor Red
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user