-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement (generate): Add variants supporting commit categories and…
… authors in release notes
- Loading branch information
1 parent
95b5680
commit 0e88731
Showing
5 changed files
with
318 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
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
104 changes: 104 additions & 0 deletions
104
...sitoryReleaseManager/generate/variants/Changes-HashSubjectAuthor-NoMerges-Categorized.ps1
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,104 @@ | ||
function Changes-HashSubjectAuthor-NoMerges-Categorized { | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory=$true)] | ||
[ValidateScript({Test-Path -Path $_ -PathType Container})] | ||
[string]$Path | ||
, | ||
[Parameter(Mandatory=$true)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$TagName | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
try { | ||
$previousRelease = Get-RepositoryReleasePrevious -Path $Path -Ref $TagName -ErrorAction SilentlyContinue | ||
if ($previousRelease) { | ||
"Previous release:" | Write-Verbose | ||
$previousRelease | Write-Verbose | ||
} | ||
$funcArgs = @{ | ||
Path = $Path | ||
FirstRef = $TagName | ||
PrettyFormat = '%h %s - `%aN`' | ||
NoMerges = $true | ||
} | ||
if ($previousRelease) { $funcArgs['SecondRef'] = @($previousRelease)[0] } | ||
$commitHistory = Get-RepositoryCommitHistory @funcArgs | ||
$commitHistoryTrimmed = $commitHistory -split "`n" | % { $_.Trim() } | ? { $_ } | ||
$commitCategory = @( | ||
@{ | ||
Name = 'Feature' | ||
Title = 'Features' | ||
} | ||
@{ | ||
Name = 'Enhancement' | ||
Title = 'Enhancements' | ||
} | ||
@{ | ||
Name = 'Refactor' | ||
Title = 'Refactors' | ||
} | ||
@{ | ||
Name = 'Test' | ||
Title = 'Tests' | ||
} | ||
@{ | ||
Name = 'Fix' | ||
Title = 'Fixes' | ||
} | ||
@{ | ||
Name = 'Docs' | ||
Title = 'Documentation' | ||
} | ||
@{ | ||
Name = 'Chore' | ||
Title = 'Chores' | ||
} | ||
) | ||
$commitHistoryUncategorized = $commitHistoryTrimmed | % { | ||
if (!($_ -match "^[0-9a-f]+ (\s*\w+\s*\(\s*[a-zA-Z0-9_-]+\s*\)\s*:)(.+)")) { | ||
$_ | ||
} | ||
} | ||
$releaseBody = & { | ||
@" | ||
## Changes | ||
"@ | ||
foreach ($c in $commitCategory) { | ||
$isTitleOutputted = $false | ||
$commitHistoryTrimmed | % { | ||
if ($_ -match "^[0-9a-f]+ (\s*$($c['Name'])\s*\(\s*[a-zA-Z0-9_-]+\s*\)\s*:)(.+)") { | ||
if (!$isTitleOutputted) { | ||
@" | ||
### $($c['Title']) | ||
"@ | ||
$isTitleOutputted = $true | ||
} | ||
@" | ||
* $_ | ||
"@ | ||
} | ||
} | ||
} | ||
if ($commitHistoryUncategorized) { | ||
@" | ||
### Others | ||
"@ | ||
$commitHistoryUncategorized | % { | ||
@" | ||
* $_ | ||
"@ | ||
} | ||
} | ||
} | ||
$releaseBody | ||
}catch { | ||
Write-Error -Exception $_.Exception -Message $_.Exception.Message -Category $_.CategoryInfo.Category -TargetObject $_.TargetObject | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
...ryReleaseManager/generate/variants/VersionDate-HashSubjectAuthor-NoMerges-Categorized.ps1
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,104 @@ | ||
function VersionDate-HashSubjectAuthor-NoMerges-Categorized { | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory=$true)] | ||
[ValidateScript({Test-Path -Path $_ -PathType Container})] | ||
[string]$Path | ||
, | ||
[Parameter(Mandatory=$true)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$TagName | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
try { | ||
$previousRelease = Get-RepositoryReleasePrevious -Path $Path -Ref $TagName -ErrorAction SilentlyContinue | ||
if ($previousRelease) { | ||
"Previous release:" | Write-Verbose | ||
$previousRelease | Write-Verbose | ||
} | ||
$funcArgs = @{ | ||
Path = $Path | ||
FirstRef = $TagName | ||
PrettyFormat = '%h %s - `%aN`' | ||
NoMerges = $true | ||
} | ||
if ($previousRelease) { $funcArgs['SecondRef'] = @($previousRelease)[0] } | ||
$commitHistory = Get-RepositoryCommitHistory @funcArgs | ||
$commitHistoryTrimmed = $commitHistory -split "`n" | % { $_.Trim() } | ? { $_ } | ||
$commitCategory = @( | ||
@{ | ||
Name = 'Feature' | ||
Title = 'Features' | ||
} | ||
@{ | ||
Name = 'Enhancement' | ||
Title = 'Enhancements' | ||
} | ||
@{ | ||
Name = 'Refactor' | ||
Title = 'Refactors' | ||
} | ||
@{ | ||
Name = 'Test' | ||
Title = 'Tests' | ||
} | ||
@{ | ||
Name = 'Fix' | ||
Title = 'Fixes' | ||
} | ||
@{ | ||
Name = 'Docs' | ||
Title = 'Documentation' | ||
} | ||
@{ | ||
Name = 'Chore' | ||
Title = 'Chores' | ||
} | ||
) | ||
$commitHistoryUncategorized = $commitHistoryTrimmed | % { | ||
if (!($_ -match "^[0-9a-f]+ (\s*\w+\s*\(\s*[a-zA-Z0-9_-]+\s*\)\s*:)(.+)")) { | ||
$_ | ||
} | ||
} | ||
$releaseBody = & { | ||
@" | ||
## $TagName ($(Get-Date -UFormat '%Y-%m-%d')) | ||
"@ | ||
foreach ($c in $commitCategory) { | ||
$isTitleOutputted = $false | ||
$commitHistoryTrimmed | % { | ||
if ($_ -match "^[0-9a-f]+ (\s*$($c['Name'])\s*\(\s*[a-zA-Z0-9_-]+\s*\)\s*:)(.+)") { | ||
if (!$isTitleOutputted) { | ||
@" | ||
### $($c['Title']) | ||
"@ | ||
$isTitleOutputted = $true | ||
} | ||
@" | ||
* $_ | ||
"@ | ||
} | ||
} | ||
} | ||
if ($commitHistoryUncategorized) { | ||
@" | ||
### Others | ||
"@ | ||
$commitHistoryUncategorized | % { | ||
@" | ||
* $_ | ||
"@ | ||
} | ||
} | ||
} | ||
$releaseBody | ||
}catch { | ||
Write-Error -Exception $_.Exception -Message $_.Exception.Message -Category $_.CategoryInfo.Category -TargetObject $_.TargetObject | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
...sitoryReleaseManager/generate/variants/VersionDate-SubjectAuthor-NoMerges-Categorized.ps1
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,104 @@ | ||
function VersionDate-SubjectAuthor-NoMerges-Categorized { | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory=$true)] | ||
[ValidateScript({Test-Path -Path $_ -PathType Container})] | ||
[string]$Path | ||
, | ||
[Parameter(Mandatory=$true)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$TagName | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
try { | ||
$previousRelease = Get-RepositoryReleasePrevious -Path $Path -Ref $TagName -ErrorAction SilentlyContinue | ||
if ($previousRelease) { | ||
"Previous release:" | Write-Verbose | ||
$previousRelease | Write-Verbose | ||
} | ||
$funcArgs = @{ | ||
Path = $Path | ||
FirstRef = $TagName | ||
PrettyFormat = '%s - `%aN`' | ||
NoMerges = $true | ||
} | ||
if ($previousRelease) { $funcArgs['SecondRef'] = @($previousRelease)[0] } | ||
$commitHistory = Get-RepositoryCommitHistory @funcArgs | ||
$commitHistoryTrimmed = $commitHistory -split "`n" | % { $_.Trim() } | ? { $_ } | ||
$commitCategory = @( | ||
@{ | ||
Name = 'Feature' | ||
Title = 'Features' | ||
} | ||
@{ | ||
Name = 'Enhancement' | ||
Title = 'Enhancements' | ||
} | ||
@{ | ||
Name = 'Refactor' | ||
Title = 'Refactors' | ||
} | ||
@{ | ||
Name = 'Test' | ||
Title = 'Tests' | ||
} | ||
@{ | ||
Name = 'Fix' | ||
Title = 'Fixes' | ||
} | ||
@{ | ||
Name = 'Docs' | ||
Title = 'Documentation' | ||
} | ||
@{ | ||
Name = 'Chore' | ||
Title = 'Chores' | ||
} | ||
) | ||
$commitHistoryUncategorized = $commitHistoryTrimmed | % { | ||
if (!($_ -match "^(\s*\w+\s*\(\s*[a-zA-Z0-9_-]+\s*\)\s*:)(.+)")) { | ||
$_ | ||
} | ||
} | ||
$releaseBody = & { | ||
@" | ||
## $TagName ($(Get-Date -UFormat '%Y-%m-%d')) | ||
"@ | ||
foreach ($c in $commitCategory) { | ||
$isTitleOutputted = $false | ||
$commitHistoryTrimmed | % { | ||
if ($_ -match "^(\s*$($c['Name'])\s*\(\s*[a-zA-Z0-9_-]+\s*\)\s*:)(.+)") { | ||
if (!$isTitleOutputted) { | ||
@" | ||
### $($c['Title']) | ||
"@ | ||
$isTitleOutputted = $true | ||
} | ||
@" | ||
* $_ | ||
"@ | ||
} | ||
} | ||
} | ||
if ($commitHistoryUncategorized) { | ||
@" | ||
### Others | ||
"@ | ||
$commitHistoryUncategorized | % { | ||
@" | ||
* $_ | ||
"@ | ||
} | ||
} | ||
} | ||
$releaseBody | ||
}catch { | ||
Write-Error -Exception $_.Exception -Message $_.Exception.Message -Category $_.CategoryInfo.Category -TargetObject $_.TargetObject | ||
} | ||
} |