From 55b354b4f2dae0cdaff9bb56b9b75ae828abd20b Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 24 Sep 2024 22:10:22 -0700 Subject: [PATCH] docs: ChangesByUserName example ( Fixes #293 ) --- Examples/ChangesByUserName.ugit.ps1 | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Examples/ChangesByUserName.ugit.ps1 diff --git a/Examples/ChangesByUserName.ugit.ps1 b/Examples/ChangesByUserName.ugit.ps1 new file mode 100644 index 00000000..feef15b8 --- /dev/null +++ b/Examples/ChangesByUserName.ugit.ps1 @@ -0,0 +1,40 @@ +<# +.SYNOPSIS + Generates a Mermaid graph of changes by username. +.DESCRIPTION + Generates a Mermaid graph of changes by username, for the current branch. +#> +param() + +$gitRemote = git remote +$headBranch = git remote | + Select-Object -First 1 | + git remote show | + Select-Object -ExpandProperty HeadBranch + +$currentBranch = git branch | ? IsCurrentBranch +if ($currentBranchName -eq $headBranch) { + Write-Warning "Not graphing the main branch." + return +} + +$currentBranchCommits = git log "$($gitRemote.RemoteName)/$headBranch..$CurrentBranch" +$changesByUserName = $currentBranchCommits | + Group-Object GitUserName -NoElement + +if ($env:GITHUB_STEP_SUMMARY) { +" +~~~mermaid +$( +@( +"pie title Changes by UserName" +foreach ($changeSet in $changesByUserName) { + (' ' * 4) + '"' + $($changeSet.Name) + '"' + ' : ' + ($changeSet.Group.Count) +} +) -join [Environment]::NewLine) +~~~ + +" | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY +} +