Skip to content

Commit 3067eaf

Browse files
azure-sdkraych1
andauthored
Sync eng/common directory with azure-sdk-tools for PR 6222 (Azure#35212)
* Updated typespec common script * Updated per the review comment --------- Co-authored-by: raychen <[email protected]>
1 parent f941be2 commit 3067eaf

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

eng/common/scripts/TypeSpec-Project-Process.ps1

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ $repoRootPath = (Join-Path $PSScriptRoot .. .. ..)
102102
$repoRootPath = Resolve-Path $repoRootPath
103103
$repoRootPath = $repoRootPath -replace "\\", "/"
104104
$tspConfigPath = Join-Path $repoRootPath 'tspconfig.yaml'
105+
$tmpTspConfigPath = $tspConfigPath
105106
# example url of tspconfig.yaml: https://github.com/Azure/azure-rest-api-specs-pr/blob/724ccc4d7ef7655c0b4d5c5ac4a5513f19bbef35/specification/containerservice/Fleet.Management/tspconfig.yaml
106107
if ($TypeSpecProjectDirectory -match '^https://github.com/(?<repo>Azure/azure-rest-api-specs(-pr)?)/blob/(?<commit>[0-9a-f]{40})/(?<path>.*)/tspconfig.yaml$') {
107108
try {
108-
$TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "github.com", "raw.githubusercontent.com"
109-
$TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "/blob/", "/"
109+
$TypeSpecProjectDirectory = $TypeSpecProjectDirectory -replace "https://github.com/(.*)/(tree|blob)", "https://raw.githubusercontent.com/`$1"
110110
Invoke-WebRequest $TypeSpecProjectDirectory -OutFile $tspConfigPath -MaximumRetryCount 3
111111
}
112112
catch {
@@ -119,13 +119,25 @@ if ($TypeSpecProjectDirectory -match '^https://github.com/(?<repo>Azure/azure-re
119119
$CommitHash = $Matches["commit"]
120120
# TODO support the branch name in url then get the commithash from branch name
121121
} else {
122+
if ($TypeSpecProjectDirectory -match "^.*/(?<path>specification/.*)$") {
123+
$TypeSpecProjectDirectory = $Matches["path"]
124+
} else {
125+
Write-Error "'$TypeSpecProjectDirectory' doesn't have 'specification' in path."
126+
exit 1
127+
}
122128
$tspConfigPath = Join-Path $TypeSpecProjectDirectory "tspconfig.yaml"
123129
if (!(Test-Path $tspConfigPath)) {
124130
Write-Error "Failed to find tspconfig.yaml in '$TypeSpecProjectDirectory'"
125131
exit 1
126132
}
127133
}
134+
128135
$tspConfigYaml = Get-Content $tspConfigPath -Raw | ConvertFrom-Yaml
136+
137+
# delete the tmporary tspconfig.yaml downloaded from github
138+
if (Test-Path $tmpTspConfigPath) {
139+
Remove-Item $tspConfigPath
140+
}
129141
# call CreateUpdate-TspLocation function
130142
$sdkProjectFolder = CreateUpdate-TspLocation $tspConfigYaml $TypeSpecProjectDirectory $CommitHash $repo $repoRootPath
131143

0 commit comments

Comments
 (0)