Skip to content

Commit

Permalink
fix: GitHub detection not finding release
Browse files Browse the repository at this point in the history
This happened when the tag name had a slash. For example, @standardnotes/desktop@[version]
  • Loading branch information
russellbanks committed Jan 27, 2023
1 parent 6bd7036 commit ff093db
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/kotlin/detection/GitHubDetection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ class GitHubDetection(url: Url) : KoinComponent {
init {
require(url.host.equals(other = gitHubWebsite, ignoreCase = true)) { "Url must be a GitHub Url" }
CoroutineScope(Dispatchers.IO).launch {
val tag = url.pathSegments.dropLast(1).last()
val repository = githubImpl.github.await().getRepository("${url.pathSegments[1]}/${url.pathSegments[2]}")
val release: GHRelease? = runCatching { repository.getReleaseByTagName(tag) }.getOrNull()
val pathSegments = url.pathSegments.filterNot { it.isBlank() }
val tag = pathSegments.dropLast(1).last()
val repository = githubImpl.github.await().getRepository("${pathSegments[0]}/${pathSegments[1]}")
val release: GHRelease? = runCatching {
repository.listReleases().find { it.tagName.contains(other = tag, ignoreCase = true) }
}.getOrNull()
val asset = release?.listAssets()?.firstOrNull { Url(it.browserDownloadUrl).decodeHex() == url.decodeHex() }
releaseDate = async { asset?.let { LocalDate.ofInstant(it.createdAt.toInstant(), ZoneId.systemDefault()) } }
license = async {
Expand Down

0 comments on commit ff093db

Please sign in to comment.