Skip to content

Commit

Permalink
Release fix for regression in update message
Browse files Browse the repository at this point in the history
  • Loading branch information
opwvhk committed Mar 29, 2024
1 parent 1c8ab3b commit 67a3243
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 24 deletions.
27 changes: 20 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ val lastBuild = provider {
}

group = "net.sf.opk"
version = "223.3.0-SNAPSHOT"
version = "221.4.3"

repositories {
mavenCentral()
mavenLocal()
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(11))
//languageVersion.set(JavaLanguageVersion.of(17))
}
}

Expand Down Expand Up @@ -62,7 +63,8 @@ intellij {
// Last minor versions differ, and the PSIViewer versions are not regular
// Also, tests require the base plugin (java/PythonCore; so don't remove it even if the plugin does not need it)

type.set("IC"); version.set("2022.3.3"); plugins.addAll("com.intellij.java", "PsiViewer:2022.3")
type.set("IC"); version.set("2022.1.4"); plugins.addAll("com.intellij.java", "PsiViewer:221-SNAPSHOT")
//type.set("IC"); version.set("2022.3.3"); plugins.addAll("com.intellij.java", "PsiViewer:2022.3")
//type.set("IC"); version.set("2023.1.6"); plugins.addAll("com.intellij.java", "PsiViewer:231-SNAPSHOT")
// From here, refactor code for compatibility / deprecated code usage
//type.set("IC"); version.set("2023.2.6"); plugins.addAll("com.intellij.java", "PsiViewer:232.2")
Expand Down Expand Up @@ -107,11 +109,16 @@ tasks {
systemProperty("idea.force.use.core.classloader", "true")
}

runIde {
jvmArgs("-XX:+UnlockDiagnosticVMOptions")
}

patchPluginXml {
version.set(project.version.toString())
// Notes on versions: usually the last 3 major releases represent about 80% of the users.
// See https://plugins.jetbrains.com/docs/marketplace/product-versions-in-use-statistics.html for more information.
sinceBuild.set("223") // Version 2022.3
sinceBuild.set("221") // Version 2022.1
//sinceBuild.set("223") // Version 2022.3
// Find last EAP version (the build version until the first dot):
// curl 'https://data.services.jetbrains.com/products/releases?code=IIU&code=IIC&code=PCP&code=PCC&latest=true&type=eap' 2>/dev/null|jq -r '.[][0].build'|cut -d . -f 1|sort -r|head -n 1
untilBuild.set(lastBuild)
Expand All @@ -120,11 +127,17 @@ tasks {
<li>Added inspection suggesting the schema syntax where appropriate</li>
</ul>
*/
/*
<p>Version 223.3.0:</p>
<ul data-version="223.3.0">
<li>Using IntelliJ version 2022.3.3 to test</li>
</ul>
*/
//language=HTML
var changeLog = """
<p>Version 223.3.0:</p>
<ul data-version="223.3.0">
<li>Using IntelliJ version 2022.3.3 to test</li>
<p>Version 221.4.3:</p>
<ul data-version="221.4.2">
<li>Fix regression in update notifications</li>
</ul>
<p>Version 221.4.2:</p>
<ul data-version="221.4.2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ private void checkForReplacedPlugin(@NotNull Project project, String myName) {
IdeaPluginDescriptor descriptor = PluginManagerCore.getPlugin(OLD_PLUGIN_ID);
if (descriptor != null && !PluginManagerCore.isDisabled(OLD_PLUGIN_ID)) {

// The old Avro plugin by Abigail Buccaneer is both installed and enabled. This can cause problems, so offer to disable it.
// The old Avro plugin by Abigail Buccaneer is both installed and enabled.
// This can cause problems, so offer to disable it.

String offendingPluginName = descriptor.getName();
// Reuses the strings used by the PluginReplacement extension point, but now the other way around.
Expand All @@ -80,19 +81,20 @@ private void checkForReplacedPlugin(@NotNull Project project, String myName) {
myName);

AvroIdlNotifications.showNotification(project, NotificationType.WARNING, title, message,
notification -> notification.addAction(
NotificationAction.createSimple(IdeBundle.message("button.disable"), () -> {
PluginManager.disablePlugin(OLD_PLUGIN_ID.getIdString());
notification.expire();
}))
.addAction(NotificationAction.createSimple(Messages.getNoButton(), notification::expire)));
notification -> notification
.addAction(NotificationAction.createSimpleExpiring(IdeBundle.message("button.disable"),
() -> PluginManager.disablePlugin(OLD_PLUGIN_ID.getIdString())))
.addAction(NotificationAction.createSimpleExpiring(Messages.getNoButton(), () -> {})));
}
}


private void notifyUserOfUpdate(@NotNull Project project, @NotNull IdeaPluginDescriptor plugin,
@NotNull String newVersion, @Nullable String oldVersion) {
String changeNotes = plugin.getChangeNotes();
String notificationTitle = oldVersion == null ?
plugin.getName() + " " + newVersion + " installed." :
plugin.getName() + " updated to version " + newVersion;
Consumer<Notification> addNotificationActions = notification -> {
// Values for idToSelect are in searchableOptions.xml; use this XPath: /option/configurable[configurable_name="AvroIDL"]@id
// (note: searchableOptions.xml is created when building the plugin)
Expand All @@ -106,23 +108,25 @@ private void notifyUserOfUpdate(@NotNull Project project, @NotNull IdeaPluginDes
.browse(URI.create("https://github.com/opwvhk/avro-schema-support/issues"))));
};

String notificationTitle = oldVersion == null ?
plugin.getName() + " " + newVersion + " installed." :
plugin.getName() + " updated to version " + newVersion;

if (oldVersion != null && !oldVersion.equals(newVersion) && changeNotes != null) {
StringBuilder changes = collectNewChanges(oldVersion, changeNotes);
AvroIdlNotifications.showNotification(project, NotificationType.INFORMATION,
notificationTitle, "This is what has changed:</b><br/><br/>" + changes,
addNotificationActions);
if (oldVersion != null) {
CharSequence changes = collectNewChanges(oldVersion, changeNotes);
if (changes.length() > 0) {
AvroIdlNotifications.showNotification(project, NotificationType.INFORMATION,
notificationTitle, "This is what has changed:</b><br/><br/>" + changes,
addNotificationActions);
}
} else {
AvroIdlNotifications.showNotification(project, NotificationType.INFORMATION, notificationTitle, null,
addNotificationActions);
}
}

@NotNull
private static StringBuilder collectNewChanges(@NotNull String oldVersion, String changeNotes) {
private static CharSequence collectNewChanges(@NotNull String oldVersion, String changeNotes) {
if (changeNotes == null) {
return "";
}

// Collect the changes since the previously installed version (but for at most 3 versions).
StringBuilder changes = new StringBuilder();
Matcher matcher = CHANGE_NOTES_PATTERN.matcher(changeNotes);
Expand Down

0 comments on commit 67a3243

Please sign in to comment.