@@ -52,8 +52,12 @@ $Script:powershell_team = @(
52
52
53
53
$Script :powershell_team_emails = @ (
54
54
" tylerl0706@gmail.com"
55
+ " rjmholt@gmail.com"
55
56
)
56
57
58
+ # Very active contributors; keep their email-login mappings here to save a few queries to Github.
59
+ $Script :community_login_map = @ {}
60
+
57
61
class CommitNode {
58
62
[string ] $Hash
59
63
[string []] $Parents
@@ -148,6 +152,66 @@ function New-CommitNode
148
152
}
149
153
}
150
154
155
+ function Get-PRNumberFromCommitSubject
156
+ {
157
+ param (
158
+ [string ]$CommitSubject
159
+ )
160
+
161
+ if (-not $CommitSubject )
162
+ {
163
+ return $null
164
+ }
165
+
166
+ if (-not ($CommitSubject -match ' (.*)\(#(\d+)\)$' ))
167
+ {
168
+ return $null
169
+ }
170
+
171
+ return @ {
172
+ Message = $Matches [1 ]
173
+ PR = $Matches [2 ]
174
+ }
175
+ }
176
+
177
+ function New-ChangeLogEntry
178
+ {
179
+ param (
180
+ [ValidateNotNullOrEmpty ()][string ]$RepositoryName ,
181
+ [ValidateNotNullOrEmpty ()][string ]$CommitMessage ,
182
+ [int ]$PRNumber ,
183
+ [string ]$UserToThank ,
184
+ [switch ]$IsBreakingChange
185
+ )
186
+
187
+ $repoUrl = " https://github.com/PowerShell/$RepositoryName "
188
+
189
+ $entry = if ($PRNumber )
190
+ {
191
+ " - [$RepositoryName #$PRNumber ]($repoUrl /pulls/$PRNumber ) -"
192
+ }
193
+ else
194
+ {
195
+ " - [$RepositoryName ]($repoUrl ) -"
196
+ }
197
+
198
+ $entry += " `n "
199
+
200
+ if ($IsBreakingChange )
201
+ {
202
+ $entry += " [Breaking Change] "
203
+ }
204
+
205
+ $entry += $CommitMessage
206
+
207
+ if ($UserToThank )
208
+ {
209
+ $entry += " (Thanks @$UserToThank !)"
210
+ }
211
+
212
+ return $entry
213
+ }
214
+
151
215
# #############################
152
216
# . SYNOPSIS
153
217
# Generate the draft change log of the git repo in the current directory
@@ -179,6 +243,9 @@ function Get-ChangeLog
179
243
[Parameter (Mandatory )]
180
244
[string ]$RepoUri ,
181
245
246
+ [Parameter (Mandatory )]
247
+ [string ]$RepoName ,
248
+
182
249
[Parameter ()]
183
250
[switch ]$HasCherryPick
184
251
)
@@ -233,31 +300,39 @@ function Get-ChangeLog
233
300
$new_commits = $new_commits_during_last_release + $new_commits_after_last_release
234
301
}
235
302
236
- # They are very active contributors, so we keep their email-login mappings here to save a few queries to Github.
237
- $community_login_map = @ {}
238
-
239
303
foreach ($commit in $new_commits ) {
240
- if ($commit.AuthorEmail.EndsWith (" @microsoft.com" ) -or $powershell_team -contains $commit.AuthorName -or $powershell_team_emails -contains $commit.AuthorEmail ) {
241
- $commit.ChangeLogMessage = " - {0}" -f $commit.Subject
242
- } else {
243
- if ($community_login_map.ContainsKey ($commit.AuthorEmail )) {
244
- $commit.AuthorGitHubLogin = $community_login_map [$commit.AuthorEmail ]
245
- } else {
304
+ $messageParts = Get-PRNumberFromCommitSubject $commit.Subject
305
+ if ($messageParts )
306
+ {
307
+ $message = $messageParts.Message
308
+ $prNumber = $messageParts.PR
309
+ }
310
+ else
311
+ {
312
+ $message = $commit.Subject
313
+ }
314
+
315
+ if (-not ($commit.AuthorEmail.EndsWith (" @microsoft.com" ) -or ($powershell_team -contains $commit.AuthorName ) -or ($powershell_team_emails -contains $commit.AuthorEmail )))
316
+ {
317
+ if ($Script :community_login_map.ContainsKey ($commit.AuthorEmail ))
318
+ {
319
+ $commit.AuthorGitHubLogin = $Script :community_login_map [$commit.AuthorEmail ]
320
+ }
321
+ else
322
+ {
246
323
$uri = " $RepoUri /commits/$ ( $commit.Hash ) "
247
324
$response = Invoke-WebRequest - Uri $uri - Method Get - Headers $header - ErrorAction SilentlyContinue
248
325
if ($response )
249
326
{
250
327
$content = ConvertFrom-Json - InputObject $response.Content
251
328
$commit.AuthorGitHubLogin = $content.author.login
252
- $community_login_map [$commit.AuthorEmail ] = $commit.AuthorGitHubLogin
329
+ $Script : community_login_map [$commit.AuthorEmail ] = $commit.AuthorGitHubLogin
253
330
}
254
331
}
255
- $commit .ChangeLogMessage = " - {0} (Thanks @{1}!) " -f $commit .Subject , $commit.AuthorGitHubLogin
332
+ $userToThank = $commit.AuthorGitHubLogin
256
333
}
257
334
258
- if ($commit.IsBreakingChange ) {
259
- $commit.ChangeLogMessage = " {0} [Breaking Change]" -f $commit.ChangeLogMessage
260
- }
335
+ $commit.ChangeLogMessage = New-ChangeLogEntry - RepositoryName $RepoName - CommitMessage $message - PRNumber $prNumber - UserToThank $userToThank - IsBreakingChange:$commit.IsBreakingChange
261
336
}
262
337
263
338
$new_commits | Sort-Object - Descending - Property IsBreakingChange | ForEach-Object - MemberName ChangeLogMessage
@@ -301,9 +376,9 @@ function Get-PowerShellExtensionChangeLog {
301
376
[switch ]$HasCherryPick
302
377
)
303
378
304
- $vscodePowerShell = Get-ChangeLog - LastReleaseTag $LastReleaseTag - Token $Token - HasCherryPick:$HasCherryPick.IsPresent - RepoUri ' https://api.github.com/repos/PowerShell/vscode-powershell'
379
+ $vscodePowerShell = Get-ChangeLog - LastReleaseTag $LastReleaseTag - Token $Token - HasCherryPick:$HasCherryPick.IsPresent - RepoUri ' https://api.github.com/repos/PowerShell/vscode-powershell' - RepoName ' vscode-PowerShell '
305
380
Push-Location ../ PowerShellEditorServices
306
- $pses = Get-ChangeLog - LastReleaseTag $LastReleaseTag - Token $Token - HasCherryPick:$HasCherryPick.IsPresent - RepoUri ' https://api.github.com/repos/PowerShell/PowerShellEditorServices'
381
+ $pses = Get-ChangeLog - LastReleaseTag $LastReleaseTag - Token $Token - HasCherryPick:$HasCherryPick.IsPresent - RepoUri ' https://api.github.com/repos/PowerShell/PowerShellEditorServices' - RepoName ' PowerShellEditorServices '
307
382
Pop-Location
308
383
309
384
return @"
0 commit comments