Skip to content

Commit 0fe4a1e

Browse files
committed
Move intentcodes to config, add Audience
1 parent 681293c commit 0fe4a1e

1 file changed

Lines changed: 19 additions & 42 deletions

File tree

PSGitChangeLog/Public/Get-GitHistory.Tools.ps1

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
[cmdletbinding()]
1919

2020
param(
21-
$Level
21+
[ValidateSet("Public", "Internal")]
22+
[string]
23+
$Audience
2224
,
2325
[string]
2426
$WorkDir
@@ -53,40 +55,10 @@
5355

5456
$CurrentBranch = $env:Build_SourceBranchName
5557

56-
$CommitCodes = @(
57-
@{
58-
code = '🐛', '🚑', 'bf:', 'bug:', 'prob:'
59-
description = 'Bugs, Problems'
60-
DefaultAudience = 'all'
61-
Order = 2
62-
}, @{
63-
code = '👌', '📦', '', 'new:', 'impr:'
64-
description = 'New features, Improvements'
65-
DefaultAudience = 'all'
66-
Order = 1
67-
}, @{
68-
code = '👷‍♂️', '', '', 'ci:', 'cfg:', 'adm:', '💚'
69-
description = 'Configuration, Testing'
70-
DefaultAudience = 'internal'
71-
Order = 4
72-
}, @{
73-
code = '📝'
74-
description = 'Documentation'
75-
DefaultAudience = 'internal'
76-
Order = 3
77-
}, @{
78-
code = '', '', '🎨', 'rf:', 'opt:'
79-
description = 'Code Optimization, Refactoring'
80-
DefaultAudience = 'all'
81-
Order = 5
82-
}, @{
83-
code = 'Other'
84-
description = 'Other'
85-
DefaultAudience = 'all'
86-
Order = 6
87-
}
88-
)
89-
$Omit = 'RE:', 'Merged', 'azure-pipelines.yml edited online with Bitbucket'
58+
$config = Import-PowerShellDataFile -Path $PSScriptRoot/../PSGitChangeLog.Config.psd1
59+
$Intents = $config.Intents
60+
61+
$Omit = $config.Omit
9062
}
9163
Process {
9264
If (!$ProjectName) {
@@ -121,9 +93,13 @@
12193
#Skip output if match with Omit
12294
If ($Omit | Where-Object { $Commit.Subject -match $_ }) { Continue }
12395

124-
$CommitCode = $CommitCodes.Code | Where-Object { $Commit.Subject -match $_ } | Select-Object -First 1
125-
If ( $null -eq $CommitCode) {
126-
$CommitCode = 'Other'
96+
$IntentCode = $Intents.Code | Where-Object { $Commit.Subject -match $_ } | Select-Object -First 1
97+
If ( $null -eq $IntentCode) {
98+
$IntentCode = 'Other'
99+
}
100+
$Intent = $Intents | Where-Object { $_.Code -contains $IntentCode }
101+
If ($Audience -eq 'Public' -and $Intent.DefaultAudience -eq 'internal') {
102+
Continue
127103
}
128104
If ($Commit.Subject.Length -lt $RequiredCommitMessageLength) {
129105
Write-Host "Commit message: $message is considered too short ($RequiredCommitMessageLength). Ommitting from changelog..."
@@ -136,14 +112,15 @@
136112
ReleaseVersionid = $TagSemVerId
137113
ReleaseCommit = $TagCommit
138114
ReleaseDate = $TagDate
139-
IntentCode = $CommitCode
140-
Intent = ($CommitCodes | Where-Object { $_.Code -contains $CommitCode }).Description
141-
Audience = ($CommitCodes | Where-Object { $_.Code -contains $CommitCode }).DefaultAudience
115+
IntentCode = $IntentCode
116+
Intent = $Intent.Description
117+
Audience = $Intent.DefaultAudience
142118
Message = $Commit.Subject
143119
IssueKey = $IssueKey
144120
CommitId = $Commit.CommitId
145-
Order = ($CommitCodes | Where-Object { $_.Code -contains $CommitCode }).Order
121+
Order = $Intents.Order
146122
}
123+
147124
Write-Output $log
148125
} #ForEach
149126

0 commit comments

Comments
 (0)