Skip to content

Commit

Permalink
Fix tag parsing in GitHub project args
Browse files Browse the repository at this point in the history
  • Loading branch information
juraj-hrivnak committed Sep 25, 2024
1 parent 779b67a commit bec3867
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/commonMain/kotlin/teksturepako/pakku/cli/arg/ProjectArg.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,17 @@ fun splitGitHubArg(arg: String): Result<ProjectArg.GitHubArg, ActionError>
val owner = splitArg.getOrNull(0) ?: return Err(EmptyArg("GitHub project"))
val repo = splitArg.getOrNull(1) ?: return Err(ArgFailed(arg, "GitHub project"))

val tag = if ("@" in arg) arg.substringAfter("@") else
val tag = when
{
arg.replace(".*(tag|tree)/".toRegex(), "").split("/").getOrNull(0)
"@" in arg ->
{
arg.substringAfter("@")
}
".*github.com/".toRegex() in arg && ".*(tag|tree)/".toRegex() in arg ->
{
arg.replace(".*(tag|tree)/".toRegex(), "").split("/").getOrNull(0)
}
else -> null
}

return Ok(ProjectArg.GitHubArg(owner, repo, tag, rawArg = arg))
Expand Down

0 comments on commit bec3867

Please sign in to comment.