Skip to content

Commit cfefd91

Browse files
committed
fix(abg): do not use double slash for top-level action URL
1 parent 3634715 commit cfefd91

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/domain/ActionCoords.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public val ActionCoords.repoName: String get() =
2727
* action lives.
2828
*/
2929
public val ActionCoords.subName: String get() =
30-
if (isTopLevel) "" else name.substringAfter("/")
30+
if (isTopLevel) "" else "/${name.substringAfter("/")}"
3131

3232
internal fun String.toActionCoords(): ActionCoords {
3333
val (ownerAndName, version) = this.split('@')

action-binding-generator/src/main/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProviding.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ internal fun ActionCoords.provideTypes(
2929
?: Pair(emptyMap(), null)
3030

3131
private fun ActionCoords.actionTypesYmlUrl(gitRef: String) =
32-
"https://raw.githubusercontent.com/$owner/$repoName/$gitRef/$subName/action-types.yml"
32+
"https://raw.githubusercontent.com/$owner/$repoName/$gitRef$subName/action-types.yml"
3333

3434
private fun ActionCoords.actionTypesFromCatalog() =
3535
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
36-
"main/typings/$owner/$repoName/$version/$subName/action-types.yml"
36+
"main/typings/$owner/$repoName/$version$subName/action-types.yml"
3737

3838
private fun ActionCoords.catalogMetadata() =
3939
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
4040
"main/typings/$owner/$repoName/metadata.yml"
4141

4242
private fun ActionCoords.actionTypesYamlUrl(gitRef: String) =
43-
"https://raw.githubusercontent.com/$owner/$repoName/$gitRef/$subName/action-types.yaml"
43+
"https://raw.githubusercontent.com/$owner/$repoName/$gitRef$subName/action-types.yaml"
4444

4545
private fun ActionCoords.fetchTypingMetadata(
4646
metadataRevision: MetadataRevision,

action-binding-generator/src/test/kotlin/io/github/typesafegithub/workflows/actionbindinggenerator/typing/TypesProvidingTest.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class TypesProvidingTest :
103103
// Given
104104
val fetchUri: (URI) -> String = {
105105
when (it) {
106-
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash//action-types.yml") -> hostedByActionYml
106+
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yml") -> hostedByActionYml
107107
else -> throw IOException()
108108
}
109109
}
@@ -120,7 +120,7 @@ class TypesProvidingTest :
120120
// Given
121121
val fetchUri: (URI) -> String = {
122122
when (it) {
123-
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash//action-types.yaml") -> hostedByActionYaml
123+
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yaml") -> hostedByActionYaml
124124
else -> throw IOException()
125125
}
126126
}
@@ -137,8 +137,8 @@ class TypesProvidingTest :
137137
// Given
138138
val fetchUri: (URI) -> String = {
139139
when (it) {
140-
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash//action-types.yml") -> hostedByActionYml
141-
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash//action-types.yaml") -> hostedByActionYaml
140+
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yml") -> hostedByActionYml
141+
URI("https://raw.githubusercontent.com/some-owner/some-name/some-hash/action-types.yaml") -> hostedByActionYaml
142142
else -> throw IOException()
143143
}
144144
}
@@ -157,7 +157,7 @@ class TypesProvidingTest :
157157
when (it) {
158158
URI(
159159
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
160-
"main/typings/some-owner/some-name/v3//action-types.yml",
160+
"main/typings/some-owner/some-name/v3/action-types.yml",
161161
),
162162
-> storedInTypingCatalog
163163
else -> throw IOException()
@@ -178,12 +178,12 @@ class TypesProvidingTest :
178178
when (it) {
179179
URI(
180180
"https://raw.githubusercontent.com/some-owner/some-name/" +
181-
"some-hash//action-types.yml",
181+
"some-hash/action-types.yml",
182182
),
183183
-> hostedByActionYml
184184
URI(
185185
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
186-
"main/typings/some-owner/some-name/v3//action-types.yml",
186+
"main/typings/some-owner/some-name/v3/action-types.yml",
187187
),
188188
-> storedInTypingCatalog
189189
else -> throw IOException()
@@ -209,7 +209,7 @@ class TypesProvidingTest :
209209
-> metadata
210210
URI(
211211
"https://raw.githubusercontent.com/typesafegithub/github-actions-typing-catalog/" +
212-
"main/typings/some-owner/some-name/v4//action-types.yml",
212+
"main/typings/some-owner/some-name/v4/action-types.yml",
213213
),
214214
-> storedInTypingCatalogForOlderVersion
215215
else -> throw IOException()

0 commit comments

Comments
 (0)