Skip to content

Commit

Permalink
docs: ChangesByIssueNumber example ( Fixes #294 )
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Sep 25, 2024
1 parent 134e0fd commit f13a968
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Examples/ChangesByIssueNumber.ugit.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<#
.SYNOPSIS
Generates a Mermaid graph of changes by issue number.
.DESCRIPTION
Generates a Mermaid graph of changes by the referenced issue number, 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 Issue"
foreach ($changeSet in $changesByUserName) {
(' ' * 4) + '"' + $($changeSet.Name) + '"' + ' : ' + ($changeSet.Count)
}
) -join [Environment]::NewLine)
~~~
" |
Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY
}

0 comments on commit f13a968

Please sign in to comment.