Skip to content

Commit 94144ac

Browse files
authored
[Validate-TypeSpec.ps1] Add GitClean switch (#24933)
- Continuation of #24629
1 parent f8e61c6 commit 94144ac

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

eng/pipelines/typespec-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ jobs:
2121
condition: succeededOrFailed()
2222

2323
- pwsh: |
24-
$(Build.SourcesDirectory)/eng/scripts/Validate-TypeSpec.ps1 $(Build.SourcesDirectory)
24+
$(Build.SourcesDirectory)/eng/scripts/Validate-TypeSpec.ps1 $(Build.SourcesDirectory) -GitClean
2525
displayName: Validate All Specs
2626
condition: succeededOrFailed()

eng/pipelines/typespec-pr.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
$(Build.SourcesDirectory)/eng/scripts/Validate-TypeSpec.ps1 `
2525
$(Build.SourcesDirectory) `
2626
"origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" `
27-
"${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}"
27+
"${env:SYSTEM_PULLREQUEST_SOURCECOMMITID}" `
28+
-GitClean
2829
displayName: Validate Impacted Specs
2930
condition: succeededOrFailed()

eng/scripts/Get-TypeSpec-Folders.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ $allChangedFiles = (Get-ChildItem -path ./specification tspconfig.yaml -Recurse)
1313
$allChangedFiles = $allChangedFiles -replace '\\', '/'
1414

1515
if ([string]::IsNullOrEmpty($TargetBranch) -or [string]::IsNullOrEmpty($SourceBranch)) {
16+
if ($TargetBranch -or $SourceBranch) {
17+
throw "Please provide both target branch and source branch."
18+
}
1619
$changedFiles = $allChangedFiles
1720
}
1821
else {

eng/scripts/Validate-TypeSpec.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ param (
55
[Parameter(Position = 1, Mandatory = $false)]
66
[string]$TargetBranch,
77
[Parameter(Position = 2, Mandatory = $false)]
8-
[string]$SourceBranch
8+
[string]$SourceBranch,
9+
[Parameter(Mandatory = $false)]
10+
[switch]$GitClean
911
)
1012

1113
$exitCode = 0
@@ -25,8 +27,12 @@ if ($typespecFolders) {
2527
if ($LASTEXITCODE) {
2628
$exitCode = 1
2729
}
28-
git restore .
29-
git clean -df
30+
if ($GitClean) {
31+
Write-Host "git restore ."
32+
git restore .
33+
Write-Host "git clean -df"
34+
git clean -df
35+
}
3036
}
3137
}
3238

0 commit comments

Comments
 (0)