Skip to content

[updater] fullChangelog includes notes for releases that won't be installed with the update #9570

@AbdulrhmanGoni

Description

@AbdulrhmanGoni

Issue Description

When GitHub Releases is used as the source of pulling updates, electron-updater checks for the release that is marked as the "latest" to download and install, and if autoUpdater.fullChangelog is set to true, electron-updater will collect the notes of all releases newer than the current version to be shown as the full changelog.

The problem occurs when new releases with versions bigger/newer than the latest release come out:

Let's say users are currently running the version 2.0.0 of an app.

Then the following new releases were published on the repository:

  • 2.1.0
  • 2.2.0 (latest)
  • 2.3.0 (the newest release that's not set yet as the "latest" for some reason)

In this case electron-updater will update the app to version 2.2.0 because it's the "latest",
but when collecting the full changelog, it includes the notes of version 2.3.0 (and actually any release that is newer than the latest release) alongside the notes of 2.1.0 and 2.2.0 releases in the changelog.

This means users will see notes in the changelog about changes (notes of 2.3.0 release) that they are not going to get after updating the app.

This happens because the function that collects the full changelog only checks if the release it's collecting its notes is greater than the current version:

const versionRelease = /\/tag\/v?([^/]+)$/.exec(release.element("link").attribute("href"))![1]
if (semver.valid(versionRelease) && semver.lt(currentVersion, versionRelease)) {
releaseNotes.push({
version: versionRelease,
note: getNoteValue(release),
})
}

Suggested Solution

We just need to add a check to make sure that the release we are collecting its notes is also less than or equal to the latest release:

  const releaseNotes: Array<ReleaseNoteInfo> = []
  for (const release of feed.getElements("entry")) {
    // noinspection TypeScriptValidateJSTypes
    const versionRelease = /\/tag\/v?([^/]+)$/.exec(release.element("link").attribute("href"))![1]
-    if (semver.valid(versionRelease) && semver.lt(currentVersion, versionRelease)) {
+    if (semver.valid(versionRelease) && semver.lte(versionRelease, latestVersion) && semver.lt(currentVersion, versionRelease)) {
      releaseNotes.push({
        version: versionRelease,
        note: getNoteValue(release),
      })
    }
  }

This way we make sure the full changelog only includes the notes of the changes that users are going to get after updating the app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions