mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
Fix RIDER-116228: for What's New, hashed versions by hash only
This will allow us to not re-trigger the new What's New on any IDE version change. GitOrigin-RevId: a27f00e44f8a0518bb3081f17efa48d7ac2d83f2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3d5fccca6c
commit
df8f91bb83
@@ -80,9 +80,6 @@ internal sealed class WhatsNewContent {
|
||||
}
|
||||
}
|
||||
|
||||
fun releaseInfoEquals(other: ContentVersion): Boolean =
|
||||
year == other.year && release == other.release && eap == other.eap
|
||||
|
||||
override operator fun compareTo(other: ContentVersion): Int {
|
||||
val result = compareValuesBy(this, other, { it.year }, { Version.parseVersion(it.release) })
|
||||
return when {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.platform.whatsNew
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.util.text.nullize
|
||||
|
||||
internal class WhatsNewContentVersionChecker {
|
||||
companion object {
|
||||
@@ -25,8 +26,8 @@ internal class WhatsNewContentVersionChecker {
|
||||
return false
|
||||
}
|
||||
|
||||
val result = newVersion > savedVersion || (newVersion.releaseInfoEquals(savedVersion) && newVersion.hash != savedVersion.hash)
|
||||
LOG.info("Comparing versions $newVersion > $savedVersion: $result.")
|
||||
val result = shouldShowWhatsNew(savedVersion, newVersion)
|
||||
LOG.info("Comparing versions $newVersion and $savedVersion: $result.")
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -39,5 +40,17 @@ internal class WhatsNewContentVersionChecker {
|
||||
|
||||
PropertiesComponent.getInstance().setValue(LAST_SHOWN_EAP_VERSION_PROP, version.toString())
|
||||
}
|
||||
|
||||
internal fun shouldShowWhatsNew(
|
||||
storedVersion: WhatsNewContent.ContentVersion,
|
||||
newVersion: WhatsNewContent.ContentVersion): Boolean {
|
||||
if (storedVersion.hash.nullize() != null && newVersion.hash.nullize() != null) {
|
||||
// If both versions have hashes, then show any new content.
|
||||
return storedVersion.hash != newVersion.hash
|
||||
}
|
||||
|
||||
// At least one of the versions doesn't have a hash: compare them by versions directly, preferring the newest.
|
||||
return newVersion > storedVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.whatsNew
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
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)
|
||||
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")
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, null)
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, null)
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "10.1", null, null)
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123")
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Comparison by two hashes just compares hashes and ignores versions`() {
|
||||
var version1 = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123")
|
||||
var version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123")
|
||||
assertFalse(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "9.1", null, "1231234")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "10.1", null, "123123")
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
|
||||
version1 = WhatsNewContent.ContentVersion("2020", "10.1", null, "1231234")
|
||||
version2 = WhatsNewContent.ContentVersion("2020", "9.1", null, "123123")
|
||||
assertTrue(WhatsNewContentVersionChecker.shouldShowWhatsNew(version1, version2))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user