Skip to content

Commit

Permalink
Fix updating GitHub projects not working properly
Browse files Browse the repository at this point in the history
The issue was in combining it with the old version of the project
  • Loading branch information
juraj-hrivnak committed Dec 17, 2024
1 parent fae29ac commit ffea001
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/commonMain/kotlin/teksturepako/pakku/Version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package teksturepako.pakku

const val VERSION = "0.21.0"
const val VERSION = "0.22.0"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import teksturepako.pakku.api.platforms.GitHub
import teksturepako.pakku.api.platforms.Multiplatform.platforms
import teksturepako.pakku.api.projects.Project
import teksturepako.pakku.api.projects.UpdateStrategy
import teksturepako.pakku.api.projects.combineWith
import teksturepako.pakku.api.projects.inheritPropertiesFrom

/**
Expand Down Expand Up @@ -53,7 +52,11 @@ suspend fun updateMultipleProjectsWithFiles(

val ghProjects = ghProjectsDeferred.await().toSet()

(updatedProjects combineWith ghProjects)
updatedProjects.map { accProject ->
ghProjects.find { it.slug[GitHub.serialName] == accProject.slug[GitHub.serialName] }
?.let { newProject -> combineProjects(accProject, newProject, GitHub.serialName, numberOfFiles) }
?: accProject
}
.filter { it.updateStrategy == UpdateStrategy.LATEST && it !in projects }
.toMutableSet()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ object GitHub : Http(), Provider

val projectFiles = if (fileId == null)
{
// Multiple files
json.decodeFromString<List<GhReleaseModel>>(
this.requestBody("https://api.github.com/repos/$input/releases") ?: return null
)
.flatMap { it.toProjectFiles(project.id[this.serialName]!!).take(numberOfFiles) }
.flatMap { it.toProjectFiles(project.id[this.serialName]!!).take(1) }
.take(numberOfFiles)
}
else
{
// One file
json.decodeFromString<GhReleaseModel>(
this.requestBody("https://api.github.com/repos/$input/releases/tags/$fileId") ?: return null
).toProjectFiles(project.id[this.serialName]!!).take(numberOfFiles)
Expand Down
11 changes: 10 additions & 1 deletion src/commonMain/kotlin/teksturepako/pakku/cli/cmd/Status.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import teksturepako.pakku.api.data.ConfigFile
import teksturepako.pakku.api.data.LockFile
import teksturepako.pakku.api.platforms.Platform
import teksturepako.pakku.cli.ui.*
import teksturepako.pakku.debug


class Status: CliktCommand()
Expand Down Expand Up @@ -111,9 +112,16 @@ class Status: CliktCommand()

for (provider in updatedProject.getProviders())
{
debug { println(provider.serialName) }

val cFile = currentProject.getFilesForProvider(provider).firstOrNull()?.fileName
val uFile = updatedProject.getFilesForProvider(provider).firstOrNull()?.fileName

debug {
println(cFile)
println(updatedProject.files)
}

if (cFile == null || uFile == null || cFile == uFile) continue

val (cDiffFile, uDiffFile) = coloredStringDiff(cFile, uFile)
Expand Down Expand Up @@ -154,7 +162,7 @@ class Status: CliktCommand()
)
projects()
}
else ->
updatedProjects.size > 1 ->
{
terminal.pInfo("Following projects have a new version available:")
terminal.println(
Expand All @@ -165,6 +173,7 @@ class Status: CliktCommand()
)
projects()
}
else -> echo()
}
}
}

0 comments on commit ffea001

Please sign in to comment.