Skip to content

Commit fb00c39

Browse files
Robert Holtrjmholt
Robert Holt
authored andcommitted
Progress
1 parent 231642f commit fb00c39

File tree

6 files changed

+239
-51
lines changed

6 files changed

+239
-51
lines changed

tools/ChangelogTools.psm1

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4-
using module ./GitHubTools.psm1
4+
#requires -Version 6.0
55

6-
$script:NoThanks = @(
7-
'rjmholt'
8-
'TylerLeonhardt'
9-
'daxian-dbw'
10-
'SteveL-MSFT'
11-
'PaulHigin'
12-
)
6+
using module ./GitHubTools.psm1
137

148
class ChangelogItem
159
{

tools/GitHubTools.psm1

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
#requires -Version 6.0
5+
46
class GitCommitInfo
57
{
68
[string]$Hash
@@ -61,6 +63,33 @@ class GitHubPR : GitHubIssue
6163
}
6264
}
6365

66+
function GetGitHubHeaders
67+
{
68+
param(
69+
[Parameter()]
70+
[string]
71+
$GitHubToken,
72+
73+
[Parameter()]
74+
[string]
75+
$Accept
76+
)
77+
78+
$headers = @{}
79+
80+
if ($GitHubToken)
81+
{
82+
$headers.Authorization = "token $GitHubToken"
83+
}
84+
85+
if ($Accept)
86+
{
87+
$headers.Accept = $Accept
88+
}
89+
90+
return $headers
91+
}
92+
6493
$script:CloseKeywords = @(
6594
'close'
6695
'closes'
@@ -352,7 +381,11 @@ function Get-GitCommit
352381

353382
[Parameter()]
354383
[string]
355-
$Remote
384+
$Remote,
385+
386+
[Parameter()]
387+
[string]
388+
$GitHubToken
356389
)
357390

358391
if (-not $Remote)
@@ -375,6 +408,15 @@ function Get-GitCommit
375408
$format = '%H||%P||%aN||%aE||%s'
376409
$commits = Exec { git --no-pager log "$SinceRef..$UntilRef" --format=$format }
377410

411+
$irmParams = if ($GitHubToken)
412+
{
413+
@{ Headers = GetGitHubHeaders -GitHubToken $GitHubToken -Accept 'application/vnd.github.v3+json' }
414+
}
415+
else
416+
{
417+
@{ Headers = GetGitHubHeaders -Accept 'application/vnd.github.v3+json' }
418+
}
419+
378420
return $commits |
379421
ForEach-Object {
380422
$hash,$parents,$name,$email,$subject = $_.Split('||')
@@ -391,7 +433,7 @@ function Get-GitCommit
391433
}
392434

393435
# Query the GitHub API for more commit information
394-
$commitVal.GitHubCommitData = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/$organization/$repository/commits/$hash"
436+
$commitVal.GitHubCommitData = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/$organization/$repository/commits/$hash" @irmParams
395437

396438
# Look for something like 'This is a commit message (#1224)'
397439
$pr = [regex]::Match($subject, '\(#(\d+)\)$').Groups[1].Value
@@ -461,10 +503,7 @@ function New-GitHubPR
461503
maintainer_can_modify = $true
462504
} | ConvertTo-Json
463505

464-
$headers = @{
465-
Accept = 'application/vnd.github.v3+json'
466-
Authorization = "token $GitHubToken"
467-
}
506+
$headers = GetGitHubHeaders -GitHubToken $GitHubToken -Accept 'application/vnd.github.v3+json'
468507

469508
Invoke-RestMethod -Method Post -Uri $uri -Body $body -Headers $headers
470509
}
@@ -499,9 +538,7 @@ function Get-GitHubPR
499538

500539
if ($GitHubToken)
501540
{
502-
$params.Headers = @{
503-
Authorization = "token $GitHubToken"
504-
}
541+
$params.Headers = GetGitHubHeaders -GitHubToken $GitHubToken
505542
}
506543

507544
$prResponse = Invoke-RestMethod @params
@@ -559,9 +596,7 @@ filter Get-GitHubIssue
559596

560597
if ($GitHubToken)
561598
{
562-
$irmParams.Headers = @{
563-
Authorization = "token $GitHubToken"
564-
}
599+
$irmParams.Headers = GetGitHubHeaders -GitHubToken $GitHubToken
565600
}
566601

567602
$issueResponse = Invoke-RestMethod @irmParams
@@ -634,10 +669,7 @@ function Publish-GitHubRelease
634669

635670
$restBody = ConvertTo-Json -InputObject $restParams
636671
$uri = "https://api.github.com/repos/$Organization/$Repository/releases"
637-
$headers = @{
638-
Accept = 'application/vnd.github.v3+json'
639-
Authorization = "token $GitHubToken"
640-
}
672+
$headers = GetGitHubHeaders -GitHubToken $GitHubToken -Accept 'application/vnd.github.v3+json'
641673

642674
$response = Invoke-RestMethod -Method Post -Uri $uri -Body $restBody -Headers $headers
643675

@@ -664,9 +696,7 @@ function Publish-GitHubRelease
664696
}
665697

666698
$assetUri = "${assetBaseUri}?name=$fileName"
667-
$headers = @{
668-
Authorization = "token $GitHubToken"
669-
}
699+
$headers = GetGitHubHeaders -GitHubToken $GitHubToken
670700
# This can be very slow, but it does work
671701
$null = Invoke-RestMethod -Method Post -Uri $assetUri -InFile $asset -ContentType $contentType -Headers $headers
672702
}

tools/changelog/updateChangelog.ps1

Lines changed: 182 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,196 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
#requires -Version 6.0
5+
16
using module ../ChangelogTools.psm1
27
using module ../GitHubTools.psm1
38

49
param(
10+
[Parameter(Mandatory)]
11+
[string]
12+
$GitHubToken,
13+
14+
[Parameter(Mandatory)]
15+
[string]
16+
$SinceRef,
17+
18+
[Parameter()]
19+
[string]
20+
$UntilRef = 'HEAD',
21+
522
[Parameter()]
23+
[string]
624
$RepositoryLocation = (Resolve-Path "$PSScriptRoot/../../")
725
)
826

27+
class ChangelogEntry
28+
{
29+
[uri]$IssueLink
30+
[uri]$PRLink
31+
[string]$Category
32+
[string[]]$Tags
33+
[string]$Text
34+
[string]$Thanks
35+
[ChangelogItem]$CLItem
36+
}
37+
38+
class ChangeLog
39+
{
40+
ChangeLog()
41+
{
42+
$this.Sections = [System.Collections.Generic.Dictionary[string, ChangelogEntry]]::new()
43+
}
44+
45+
[string]$ReleaseName
46+
[datetime]$Date
47+
[string]$Preamble
48+
[System.Collections.Generic.Dictionary[string, ChangelogEntry]]$Sections
49+
}
50+
951
$script:ChangelogConfig = @{
10-
DefaultCategory = 'General'
11-
Categories = @(
12-
@{
13-
Name = 'Debugging'
14-
Issue = 'Area-Debugging'
15-
},
16-
@{
17-
Name = 'CodeLens'
18-
Issue = 'Area-CodeLens'
19-
},
20-
@{
21-
Name = 'Script Analysis'
22-
Issue = 'Area-Script Analysis'
23-
},
24-
@{
25-
Name = 'Formatting'
26-
Issue = 'Area-Formatting'
27-
},
28-
@{
29-
Name = 'Integrated Console'
30-
Issue = 'Area-Integrated Console','Area-PSReadLine'
52+
DateFormat = 'dddd, dd MMMM yyyy'
53+
NoThanks = @(
54+
'rjmholt'
55+
'TylerLeonhardt'
56+
'daxian-dbw'
57+
'SteveL-MSFT'
58+
'PaulHigin'
59+
)
60+
Ignore = @{
61+
Users = 'dependabot[bot]'
62+
Labels = @{
63+
Commit = 'Ignore'
64+
}
65+
}
66+
TagLabels = @{
67+
'Issue-Enhancement' = 'Feature'
68+
'Issue-Bug' = 'BugFix'
69+
}
70+
ChangeCategories = @{
71+
Default = @{
72+
Name = 'General'
73+
Issue = 'Area-General'
3174
}
32-
@{
33-
Name = Intellisense
34-
Issue = 'Area-Intellisense'
75+
Categories = [ordered]@{
76+
Debugging = @{
77+
Issue = 'Area-Debugging'
78+
}
79+
CodeLens = @{
80+
Issue = 'Area-CodeLens'
81+
}
82+
'Script Analysis' = @{
83+
Issue = 'Area-Script Analysis'
84+
}
85+
Formatting = @{
86+
Issue = 'Area-Formatting'
87+
}
88+
'Integrated Console' = @{
89+
Issue = 'Area-Integrated Console','Area-PSReadLine'
90+
}
91+
'Intellisense' = @{
92+
Issue = 'Area-Intellisense'
93+
}
94+
}
95+
}
96+
}
97+
98+
filter FilterIgnoredCommits
99+
{
100+
param(
101+
[Parameter(Mandatory, ValueFromPipeline)]
102+
[ChangelogItem]
103+
$CLItem,
104+
105+
[Parameter]
106+
[string[]]
107+
$IgnoreUser,
108+
109+
[Parameter()]
110+
[string[]]
111+
$IgnoreCommitLabel
112+
)
113+
114+
if ($CLItem.ContributingUser -in $IgnoreUser)
115+
{
116+
return
117+
}
118+
119+
foreach ($commitLabel in $CLItem.Commit.CommitLabels)
120+
{
121+
if ($commitLabel -in $IgnoreCommitLabel)
122+
{
123+
return
35124
}
125+
}
126+
127+
return $CLItem
128+
}
129+
130+
filter AssembleCLEntry
131+
{
132+
param(
133+
[Parameter(Mandatory, ValueFromPipeline)]
134+
[ChangelogItem]
135+
$CLItem,
136+
137+
[Parameter()]
138+
[string]
139+
$Organization = 'PowerShell',
140+
141+
[Parameter()]
142+
[string]
143+
$Repository = 'vscode-powershell'
36144
)
145+
146+
[string[]]$tags = @()
147+
:labelLoop foreach ($issueLabel in $CLItem.ClosedIssues.Labels)
148+
{
149+
if (-not $entryCategory)
150+
{
151+
foreach ($category in $script:ChangelogConfig.ChangeCategories.Categories.GetEnumerator())
152+
{
153+
if ($issueLabel -in $category.Value.Issue)
154+
{
155+
$entryCategory = $category.Key
156+
continue :labelLoop
157+
}
158+
}
159+
}
160+
161+
$tag = $script:ChangelogConfig.TagLabels[$issueLabel]
162+
if ($tag)
163+
{
164+
$tags += $tag
165+
}
166+
}
167+
168+
if (-not $entryCategory)
169+
{
170+
$entryCategory = $script:ChangelogConfig.ChangeCategories.Default.Name
171+
}
172+
173+
return [ChangelogEntry]@{
174+
IssueLink = if ($CLItem.IssueNumber -ge 0) { "https://github.com/$Organization/$Repository/issues/$($CLItem.IssueNumber)" }
175+
PRLink = if ($CLItem.PRNumber -ge 0) { "https://github.com/$Organization/$Repository/$($CLItem.PRNumber)" }
176+
Thanks = if ($CLItem.ContributingUser -notin $script:NoThanks) { $CLItem.ContributingUser }
177+
Category = $entryCategory
178+
Tags = $tags
179+
CLItem = $CLItem
180+
}
181+
}
182+
183+
function AssembleCLObject
184+
{
185+
186+
}
187+
188+
function BuildChangelog
189+
{
190+
37191
}
38192

193+
$changeLog = Get-GitCommit -SinceRef $SinceRef -UntilRef $UntilRef -GitHubToken $GitHubToken |
194+
Get-ChangelogItemFromCommit -GitHubToken $GitHubToken |
195+
FilterIgnoredCommits -IgnoreUser $ignore.Users -IgnoreCommitLabel $ignore.Labels.Commit |
196+
AssembleCLEntry

tools/postReleaseScripts/updateAzureDataStudio.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
#requires -Version 6.0
5+
46
param(
57
[Parameter(Mandatory)]
68
[string]

tools/postReleaseScripts/updateExtensionVersions.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33

4+
#requires -Version 6.0
5+
46
[CmdletBinding(DefaultParameterSetName='Increment')]
57
param(
68
[Parameter(ParameterSetName='Increment')]

0 commit comments

Comments
 (0)