Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Define backports for autoupdater #3171

Open
wants to merge 3 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.features.misc.update

import at.hannibal2.skyhanni.utils.system.ModVersion
import at.hannibal2.skyhanni.utils.system.PlatformUtils
import com.google.gson.JsonPrimitive
import moe.nea.libautoupdate.GithubReleaseUpdateData
Expand All @@ -11,6 +12,12 @@ import moe.nea.libautoupdate.UpdateData
*/
class CustomGithubReleaseUpdateSource(owner: String, repository: String) : GithubReleaseUpdateSource(owner, repository) {

override fun selectUpdate(updateStream: String, releases: MutableList<GithubRelease>) = when (updateStream) {
"pre" -> findLatestRelease(releases.filter { !it.isDraft && !ModVersion.fromString(it.tagName).isBackport })
"full" -> findLatestRelease(releases.filter { !it.isDraft && !it.isPrerelease })
else -> null
}
Comment on lines +15 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could in theory also just override findLatestRelease to order by the modversion:

		override fun findLatestRelease(validReleases: Iterable<GithubRelease>): UpdateData {
			return validReleases.asSequence().mapNotNull { findAsset(it) }.maxBy { ModVersion.fromString(it.tagName) }
		}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also allow for upgrading to backport releases if no betas have yet been released:

1.0.0 -> 1.0.1 (no 1.1.0 released yet)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your solution does allow this but it the version comparison that we have it the mod would mean that using this would also try and update users from the stable/backport branch to the betas which is not intended. I guess I can look into our version comparison further but I feel the current solution I have is more than enough and a backport before a beta is rare enough that it is not needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure how my change would make users upgrade to betas? The default selectUpdate function already filters for github prereleases, so the findLatestRelease function will not get any betas on the full update stream

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure how my change would make users upgrade to betas? The default selectUpdate function already filters for github prereleases, so the findLatestRelease function will not get any betas on the full update stream

iirc the problem is that when someone updates from full version to beta their update channel gets set to beta, and stays on beta, even after updating to a full version later

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc the problem is that when someone updates from full version to beta their update channel gets set to beta, and stays on beta, even after updating to a full version later

I am entirely unsure how my code would ever upgrade someone to a beta. The point is to update people who already want a beta version to a newer bugfix version if no betas have been released.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again: I dont update people to betas with my suggested piece of code, so the SkyHanniMod.isBetaVersion two lines above would not come to be true.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not talking about your suggestion here, but rather about the state of the auto updater afaik


override fun findAsset(release: GithubRelease?): UpdateData? {
release ?: return null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils.system
data class ModVersion(val stable: Int, val beta: Int, val bugfix: Int) : Comparable<ModVersion> {

val isBeta get() = beta != 0
val isBackport get() = beta == 0 && bugfix != 0

inline val asString get() = toString()

Expand Down
Loading