mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
What's New: ignore content hashes for release versions
#IJPL-172278 Fixed GitOrigin-RevId: cf156478862cd65fb6afd6e19ed5e93e26006acc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1095cde6b8
commit
c698acb233
@@ -44,6 +44,16 @@ internal class WhatsNewContentVersionChecker {
|
||||
internal fun shouldShowWhatsNew(
|
||||
storedVersion: WhatsNewContent.ContentVersion,
|
||||
newVersion: WhatsNewContent.ContentVersion): Boolean {
|
||||
if (storedVersion.eap == null && newVersion.eap == null) {
|
||||
if (storedVersion.hash.nullize() == null || newVersion.hash.nullize() == null) {
|
||||
// Both versions are release ⇒ compare versions only.
|
||||
return newVersion > storedVersion
|
||||
}
|
||||
|
||||
// Both versions are release but might have the same hash ⇒ compare versions and hash.
|
||||
return newVersion > storedVersion && storedVersion.hash != newVersion.hash
|
||||
}
|
||||
|
||||
if (storedVersion.hash.nullize() != null && newVersion.hash.nullize() != null) {
|
||||
// If both versions have hashes, then show any new content (i.e., hashes are different and the version is new).
|
||||
return storedVersion.hash != newVersion.hash && newVersion >= storedVersion
|
||||
|
||||
+49
-20
@@ -8,55 +8,84 @@ import org.junit.Test
|
||||
class WhatsNewContentVersionCheckerTest {
|
||||
@Test
|
||||
fun `Comparison by version should take the highest version`() {
|
||||
val version1 = WhatsNewContent.ContentVersion("2020", "9.1", null, null)
|
||||
val version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, null)
|
||||
val version1 = WhatsNewContent.ContentVersion("2020", "9.1", 1, null)
|
||||
val version2 = WhatsNewContent.ContentVersion("2020", "10.1", 1, null)
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Comparison by version and hash should ignore the hashes`() {
|
||||
var version1 = WhatsNewContent.ContentVersion("2020", "9.1", null, null)
|
||||
var version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123")
|
||||
var version1 = WhatsNewContent.ContentVersion("2020", "9.1", 1, null)
|
||||
var version2 = WhatsNewContent.ContentVersion("2020", "10.1", 1, "123123")
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, null)
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "9.1", 1, "123123")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", 1, null)
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, null)
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "10.1", 1, "123123")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", 1, null)
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "10.1", null, null)
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123")
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "10.1", 1, null)
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", 1, "123123")
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Comparison by two hashes just compares hashes and ignores versions if the stored is older`() {
|
||||
var version1 = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123")
|
||||
var version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123")
|
||||
var version1 = WhatsNewContent.ContentVersion("2020", "9.1", 1, "123123")
|
||||
var version2 = WhatsNewContent.ContentVersion("2020", "10.1", 1, "123123")
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "9.1", null, "1231234")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123")
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "9.1", 1, "1231234")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", 1, "123123")
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "10.1", null, "1231234")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123")
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "10.1", 1, "1231234")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "9.1", 1, "123123")
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Comparison with future version`() {
|
||||
var storedVersion = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123")
|
||||
var newVersion = WhatsNewContent.ContentVersion("2020", "8.1", null, "321321")
|
||||
var storedVersion = WhatsNewContent.ContentVersion("2020", "9.1", 1, "123123")
|
||||
var newVersion = WhatsNewContent.ContentVersion("2020", "8.1", 1, "321321")
|
||||
// On the one hand, the current content differs from the stored. On the other hand, the one stored is *newer*.
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(storedVersion, newVersion))
|
||||
|
||||
storedVersion = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123")
|
||||
newVersion = WhatsNewContent.ContentVersion("2020", "9.1", null, "321321")
|
||||
storedVersion = WhatsNewContent.ContentVersion("2020", "9.1", 1, "123123")
|
||||
newVersion = WhatsNewContent.ContentVersion("2020", "9.1", 1, "321321")
|
||||
// Hash-only change ⇒ show the page.
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(storedVersion, newVersion))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ignore content hash in release version`() {
|
||||
val storedVersion = WhatsNewContent.ContentVersion("2020", "1.1", null, "123123")
|
||||
val newVersion = WhatsNewContent.ContentVersion("2020", "1.1", null, "321321")
|
||||
// Versions are equal ⇒ show nothing, even though the content differs.
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(storedVersion, newVersion))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `show new content in release version`() {
|
||||
val storedVersion = WhatsNewContent.ContentVersion("2019", "1.1", null, "123123")
|
||||
val newVersion = WhatsNewContent.ContentVersion("2020", "1.1", null, "321321")
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(storedVersion, newVersion))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `do not show old content in release version`() {
|
||||
val storedVersion = WhatsNewContent.ContentVersion("2020", "1.1", null, "123123")
|
||||
val newVersion = WhatsNewContent.ContentVersion("2019", "1.1", null, "321321")
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(storedVersion, newVersion))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `compare hashes in release and block if they are the same`() {
|
||||
val storedVersion = WhatsNewContent.ContentVersion("2020", "1.1", null, "123123")
|
||||
val newVersion = WhatsNewContent.ContentVersion("2021", "1.1", null, "123123")
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(storedVersion, newVersion))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user