0.24, and the two version numbers are one number now
Android carries a versionCode, which decides whether an install counts as an upgrade, and a versionName, which is what a person reads. They had been one apart since 0.11 was built and never published: the build after it went out as code 12 before the name was settled, and a code can never come back down. So the download page said 0.22 while every number underneath said 23, and somebody comparing the page against their own app had to know which of the two was ordering and which was a label. This release closes it by skipping the name 0.23. Code 24 with name 0.24, and from here they move together and match. Skipping a name costs nothing, because a name is a label; skipping a code would be the thing that cannot be undone. A test reads both out of the build file and fails if they ever name different releases, or if the code drops to or below the published 23. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
a8ec0bab63
commit
645896ce96
+14
-19
@@ -30,26 +30,21 @@ android {
|
||||
// and `scripts/release-manifest.sh` reads it back out of the built APK
|
||||
// to write that file, so the two cannot drift.
|
||||
//
|
||||
// Android also refuses to install an APK whose `versionCode` is
|
||||
// lower than the installed one, so a code that goes backwards makes a
|
||||
// release uninstallable for everybody already on the higher number.
|
||||
// The code is one ahead of the name, deliberately. 0.11 was built
|
||||
// and never published; the build that followed it went out
|
||||
// as versionCode 12 before the name was settled on. Going back to code
|
||||
// 11 would make the release uninstallable for anyone already on 12, see
|
||||
// the paragraph above, so the code keeps climbing and the NAME is what
|
||||
// closes the 0.10 -> 0.12 gap. They are allowed to differ: the code is
|
||||
// ordering, the name is what a person reads.
|
||||
// The NAME is what the website and the app show a person, and it now
|
||||
// matches the code rather than trailing it: somebody comparing the
|
||||
// download page against their own app should not have to know that one
|
||||
// number is ordering and the other is a label.
|
||||
// Android also refuses to install an APK whose `versionCode` is lower
|
||||
// than the installed one, so a code that goes backwards makes a release
|
||||
// uninstallable for everybody already on the higher number.
|
||||
//
|
||||
// They cannot be made equal: the code was already ahead when the name
|
||||
// was settled, and a code is never reused. So they stay one apart and
|
||||
// move together, name 0.22 with code 23, and each release moves both.
|
||||
versionCode = 23
|
||||
versionName = "0.22"
|
||||
// THE TWO NUMBERS ARE THE SAME NUMBER NOW, and that is the whole point
|
||||
// of this release. They used to differ by one: 0.11 was built and never
|
||||
// published, the build after it went out as code 12 before the name was
|
||||
// settled, and the code can never come back down. The name spent eleven
|
||||
// releases one behind, and somebody comparing the download page against
|
||||
// their own app had to know that one number is ordering and the other
|
||||
// is a label. Code 24 with name 0.24 closes it by skipping the name
|
||||
// 0.23, which costs nothing because a name is a label and may skip.
|
||||
// From here they move together and match: 25 with 0.25, 26 with 0.26.
|
||||
versionCode = 24
|
||||
versionName = "0.24"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package io.flamenet.messenger.app
|
||||
|
||||
import java.io.File
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
/**
|
||||
* `versionCode` and `versionName` name the same release.
|
||||
*
|
||||
* They used to differ by one, and the download page showed the name while
|
||||
* every internal number was the code, so somebody comparing the page against
|
||||
* their own app had to know which was which. They were made equal at code 24
|
||||
* with name 0.24 and they stay equal: a release moves both to the same number.
|
||||
*/
|
||||
class TheVersionNumbersMatchTest {
|
||||
private val build =
|
||||
File("build.gradle.kts").let {
|
||||
assertTrue(it.isFile, "this test reads app/build.gradle.kts")
|
||||
it.readText().lines().filterNot { l -> l.trimStart().startsWith("//") }
|
||||
}
|
||||
|
||||
private fun value(key: String): String {
|
||||
val line =
|
||||
build.firstOrNull { it.trimStart().startsWith("$key = ") }
|
||||
?: error("$key is not set in app/build.gradle.kts")
|
||||
return line.substringAfter("= ").trim().trim('"')
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the version name is the version code, as a name`() {
|
||||
val code = value("versionCode").toInt()
|
||||
val name = value("versionName")
|
||||
assertEquals(
|
||||
"0.$code",
|
||||
name,
|
||||
"versionCode $code and versionName $name name different releases; " +
|
||||
"they were made equal on purpose so the download page and the " +
|
||||
"app show the same number",
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `the version code never goes below what has been published`() {
|
||||
// 23 was the last code published before the two were made equal.
|
||||
// Android refuses to install a lower code over a higher one, so a
|
||||
// release at or below it is uninstallable for everybody already on it.
|
||||
assertTrue(
|
||||
value("versionCode").toInt() > 23,
|
||||
"versionCode ${value("versionCode")} is at or below the published 23",
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user