Skip to content

Commit bdee932

Browse files
Remove problematic [RepoNames] PowerShell class (#4481)
It was admittedly over-engineered and caused problems since PowerShell classes aren't imported across modules. Instead just use `ValidateSet` directly wherever the command is either use-facing or switches on the string directly.
1 parent 119d7b7 commit bdee932

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

tools/ReleaseTools.psm1

+6-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ function Update-Branch {
1616
[CmdletBinding(SupportsShouldProcess)]
1717
param(
1818
[Parameter(Mandatory)]
19-
[ValidateSet([RepoNames])]
2019
[string]$RepositoryName
2120
)
2221
Use-Repository -RepositoryName $RepositoryName -Script {
@@ -37,7 +36,6 @@ function Get-Bullets {
3736
[CmdletBinding()]
3837
param(
3938
[Parameter(Mandatory)]
40-
[ValidateSet([RepoNames])]
4139
[string]$RepositoryName,
4240

4341
[Parameter(Mandatory, ValueFromPipeline)]
@@ -97,7 +95,7 @@ function Get-Bullets {
9795

9896
# NOTE: The URL matcher must be explicit because the body of a PR may
9997
# contain other URLs with digits (like an image asset).
100-
$IssueRegex = '(' + ($CloseKeywords -join '|') + ')\s+((https://github.com/PowerShell/(?<repo>(' + ([RepoNames]::Values -join '|') + '))/issues/)|#)(?<number>\d+)'
98+
$IssueRegex = '(' + ($CloseKeywords -join '|') + ')\s+((https://github.com/PowerShell/(?<repo>(vscode-powershell|PowerShellEditorServices))/issues/)|#)(?<number>\d+)'
10199
}
102100

103101
process {
@@ -112,7 +110,7 @@ function Get-Bullets {
112110
$number = $Matches.number
113111
$repo = $Matches.repo
114112
# Handle links to issues in both repos, in both shortcode and URLs.
115-
$name = [RepoNames]::Values | Where-Object { $repo -match $_ } | Select-Object -First 1
113+
$name = ("vscode-powershell", "PowerShellEditorServices") | Where-Object { $repo -match $_ } | Select-Object -First 1
116114
"$($name ?? $RepositoryName) #$number"
117115
} else {
118116
"$RepositoryName #$($_.number)"
@@ -141,7 +139,7 @@ function Update-Changelog {
141139
[CmdletBinding(SupportsShouldProcess)]
142140
param(
143141
[Parameter(Mandatory)]
144-
[ValidateSet([RepoNames])]
142+
[ValidateSet("vscode-powershell", "PowerShellEditorServices")]
145143
[string]$RepositoryName,
146144

147145
[Parameter(Mandatory)]
@@ -228,7 +226,7 @@ function Update-Version {
228226
[CmdletBinding(SupportsShouldProcess)]
229227
param(
230228
[Parameter(Mandatory)]
231-
[ValidateSet([RepoNames])]
229+
[ValidateSet("vscode-powershell", "PowerShellEditorServices")]
232230
[string]$RepositoryName
233231
)
234232
$Version = Get-Version -RepositoryName $RepositoryName
@@ -287,7 +285,7 @@ function New-ReleasePR {
287285
[CmdletBinding(SupportsShouldProcess)]
288286
param(
289287
[Parameter(Mandatory)]
290-
[ValidateSet([RepoNames])]
288+
[ValidateSet("vscode-powershell", "PowerShellEditorServices")]
291289
[string]$RepositoryName
292290
)
293291
$Version = Get-Version -RepositoryName $RepositoryName
@@ -340,11 +338,10 @@ function New-Release {
340338
[CmdletBinding(SupportsShouldProcess)]
341339
param(
342340
[Parameter(Mandatory)]
343-
[ValidateSet([RepoNames])]
341+
[ValidateSet("vscode-powershell", "PowerShellEditorServices")]
344342
[string]$RepositoryName,
345343

346344
[Parameter(Mandatory)]
347-
[ValidateScript({ $_.StartsWith("v") })]
348345
[string]$Version
349346
)
350347
# TODO: Automate rolling a preview to a stable release.
@@ -363,11 +360,9 @@ function New-ReleaseBundle {
363360
[CmdletBinding(SupportsShouldProcess)]
364361
param(
365362
[Parameter(Mandatory)]
366-
[ValidateScript({ $_.StartsWith("v") })]
367363
[string]$PsesVersion,
368364

369365
[Parameter(Mandatory)]
370-
[ValidateScript({ $_.StartsWith("v") })]
371366
[string]$VsceVersion
372367
)
373368
"PowerShellEditorServices", "vscode-powershell" | ForEach-Object {
@@ -391,7 +386,6 @@ function New-DraftRelease {
391386
[CmdletBinding(SupportsShouldProcess)]
392387
param(
393388
[Parameter(Mandatory)]
394-
[ValidateSet([RepoNames])]
395389
[string]$RepositoryName,
396390

397391
[Parameter()]

tools/VersionTools.psm1

+2-10
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55

66
using namespace System.Management.Automation
77

8-
class RepoNames : IValidateSetValuesGenerator {
9-
# NOTE: This is super over-engineered, but it was fun.
10-
static [string[]] $Values = "vscode-powershell", "PowerShellEditorServices"
11-
[String[]] GetValidValues() { return [RepoNames]::Values }
12-
}
13-
148
$ChangelogFile = "CHANGELOG.md"
159

1610
<#
@@ -21,7 +15,7 @@ function Use-Repository {
2115
[CmdletBinding()]
2216
param(
2317
[Parameter(Mandatory)]
24-
[ValidateSet([RepoNames])]
18+
[ValidateSet("vscode-powershell", "PowerShellEditorServices")]
2519
[string]$RepositoryName,
2620

2721
[Parameter(Mandatory)]
@@ -53,7 +47,6 @@ function Use-Repository {
5347
function Get-FirstChangelog {
5448
param(
5549
[Parameter(Mandatory)]
56-
[ValidateSet([RepoNames])]
5750
[string]$RepositoryName
5851
)
5952
$Changelog = Use-Repository -RepositoryName $RepositoryName -Script {
@@ -75,7 +68,6 @@ function Get-FirstChangelog {
7568
function Get-Version {
7669
param(
7770
[Parameter(Mandatory)]
78-
[ValidateSet([RepoNames])]
7971
[string]$RepositoryName
8072
)
8173
# NOTE: The first line should always be the header.
@@ -116,7 +108,7 @@ function Test-IsPreRelease {
116108
function Test-VersionIsValid {
117109
param(
118110
[Parameter(Mandatory)]
119-
[ValidateSet([RepoNames])]
111+
[ValidateSet("vscode-powershell", "PowerShellEditorServices")]
120112
[string]$RepositoryName,
121113

122114
[Parameter(Mandatory)]

0 commit comments

Comments
 (0)