From ce0e4fcc28a9ef7a532b12f7952987d7b6ac60fd Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Wed, 25 Sep 2024 00:12:55 -0700 Subject: [PATCH] docs: ChangesByCommitType Example ( Fixes #302, re #301 ) --- Examples/ChangesByCommitType.ugit.ps1 | 46 +++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Examples/ChangesByCommitType.ugit.ps1 diff --git a/Examples/ChangesByCommitType.ugit.ps1 b/Examples/ChangesByCommitType.ugit.ps1 new file mode 100644 index 00000000..f27eca84 --- /dev/null +++ b/Examples/ChangesByCommitType.ugit.ps1 @@ -0,0 +1,46 @@ +<# +.SYNOPSIS + Generates a Mermaid graph of changes by commit type. +.DESCRIPTION + Generates a Mermaid graph of changes by the conventional commit type. +#> +param() + +Write-Information "Graphing $($MyInvocation.MyCommand.Name) for $($currentBranch.BranchName) branch." +$gitRemote = git remote +$headBranch = git remote | + Select-Object -First 1 | + git remote show | + Select-Object -ExpandProperty HeadBranch + +$currentBranch = git branch | ? IsCurrentBranch + + +$commitList = + if ($currentBranch.BranchName -ne $headBranch) { + git log "$($gitRemote.RemoteName)/$headBranch..$($CurrentBranch.BranchName)" + } else { + git log + } + +$groupedChangedSet = $commitList | + ? { $_.CommitType } | + Group-Object { $_.CommitType } -NoElement + +$mermaidDiagram = @( + "pie title Changes by Commit Type" + foreach ($changeSet in $groupedChangedSet) { + (' ' * 4),'"',$($changeSet.Name),'"',' : ',($changeSet.Count) -join '' + } +) -join [Environment]::NewLine + +if ($env:GITHUB_STEP_SUMMARY) { +" +~~~mermaid +$mermaidDiagram +~~~ + +" | + Out-File -Append -FilePath $env:GITHUB_STEP_SUMMARY +} +