Skip to content

Commit

Permalink
fix(abg): fix fetching typings for nested actions (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzema12 committed Nov 22, 2023
1 parent c42194f commit 56d1dfe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public final class io/github/typesafegithub/workflows/actionbindinggenerator/Act

public final class io/github/typesafegithub/workflows/actionbindinggenerator/ActionCoordsKt {
public static final fun getPrettyPrint (Lio/github/typesafegithub/workflows/actionbindinggenerator/ActionCoords;)Ljava/lang/String;
public static final fun getRepoName (Lio/github/typesafegithub/workflows/actionbindinggenerator/ActionCoords;)Ljava/lang/String;
public static final fun getSubName (Lio/github/typesafegithub/workflows/actionbindinggenerator/ActionCoords;)Ljava/lang/String;
public static final fun isTopLevel (Lio/github/typesafegithub/workflows/actionbindinggenerator/ActionCoords;)Z
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ public val ActionCoords.isTopLevel: Boolean get() = "/" !in name

public val ActionCoords.prettyPrint: String get() = "$owner/$name@$version"

/**
* For most actions, it's the same as [ActionCoords.name].
* For actions that aren't executed from the root of the repo, it returns the repo name.
*/
public val ActionCoords.repoName: String get() =
name.substringBefore("/")

/**
* For most actions, it's empty.
* For actions that aren't executed from the root of the repo, it returns the path relative to the repo root where the
* action lives.
*/
public val ActionCoords.subName: String get() =
if (isTopLevel) "" else name.substringAfter("/")

internal fun String.toActionCoords(): ActionCoords {
val (ownerAndName, version) = this.split('@')
val (owner, name) = ownerAndName.split('/', limit = 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ public fun deleteActionTypesYamlCacheIfObsolete() {
}
}

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

private fun ActionCoords.actionTypesMaintainedWithLibraryUrl() =
"https://raw.githubusercontent.com/typesafegithub/github-workflows-kt/main/actions/$owner/$name/$version/action-types.yml"
"https://raw.githubusercontent.com/typesafegithub/github-workflows-kt/main/actions/$owner/$repoName/$version/$subName/action-types.yml"

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

private fun ActionCoords.fetchTypingMetadata(
metadataRevision: MetadataRevision,
Expand Down

0 comments on commit 56d1dfe

Please sign in to comment.