-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: ChangesByUserName example ( Fixes #293 )
- Loading branch information
James Brundage
committed
Sep 25, 2024
1 parent
a9f7835
commit 55b354b
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|