-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(updater): ensure full changelog includes only release notes up to the latest release #9573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AbdulrhmanGoni
wants to merge
19
commits into
electron-userland:master
Choose a base branch
from
AbdulrhmanGoni:fix/fullChangelog-notes-range
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9ec5b35
fix(updater): ensure full changelog includes only release notes up to…
AbdulrhmanGoni 1bb204b
add error handling with default fallback for new logic if latest vers…
mmaietta 1014d99
Merge branch 'electron-userland:master' into fix/fullChangelog-notes-…
AbdulrhmanGoni 7d79c7c
fix the semver validation logic for release versions
AbdulrhmanGoni 2c8f301
Merge branch 'master' into fix/fullChangelog-notes-range
AbdulrhmanGoni 6262a77
ensure notes of pre-releases will be included in the full changelog
AbdulrhmanGoni a1cee41
Merge branch 'master' into fix/fullChangelog-notes-range
AbdulrhmanGoni b1916c1
add tests for semver and fix bug in `semver.gt`
mmaietta 5822a68
Merge branch 'master' into fix/fullChangelog-notes-range
mmaietta df6fb86
Merge branch 'master' into fix/fullChangelog-notes-range
mmaietta 256a58e
Merge branch 'master' into fix/fullChangelog-notes-range
AbdulrhmanGoni 37ede11
Merge branch 'electron-userland:master' into fix/fullChangelog-notes-…
AbdulrhmanGoni 5d90818
ensure releases versions in full changelog are returned without "v" p…
AbdulrhmanGoni 08d63c4
Merge branch 'master' into fix/fullChangelog-notes-range
mmaietta 30f65b0
fix the tests of `computeReleaseNotes` function
AbdulrhmanGoni 8c3a38e
Merge branch 'master' into fix/fullChangelog-notes-range
AbdulrhmanGoni 10027f3
update import style to a consistent one with other test files
AbdulrhmanGoni 99f1e1c
Merge branch 'master' into fix/fullChangelog-notes-range
AbdulrhmanGoni 3878f7d
Merge branch 'master' into fix/fullChangelog-notes-range
AbdulrhmanGoni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "electron-updater": patch | ||
| --- | ||
|
|
||
| fix(updater): ensure full changelog includes only release notes up to the latest release | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| import * as semver from "semver" | ||
| import { parseXml } from "builder-util-runtime" | ||
| import { computeReleaseNotes } from "../../../packages/electron-updater/src/providers/GitHubProvider" | ||
|
AbdulrhmanGoni marked this conversation as resolved.
Outdated
|
||
| import { expect } from "vitest" | ||
|
|
||
| describe("GitHub Provider", () => { | ||
| describe("computeReleaseNotes", () => { | ||
| it("returns single release notes string when full changelog is false", () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.0.1"/> | ||
| <content>Release 1.0.1 notes</content> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const latest = feed.element("entry") | ||
| const result = computeReleaseNotes(semver.parse("1.0.0")!, false, feed, latest) | ||
| expect(result).toEqual("Release 1.0.1 notes") | ||
| }) | ||
|
|
||
| it('treats "No content." as empty string when full changelog is false', () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.0.2"/> | ||
| <content>No content.</content> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const latest = feed.element("entry") | ||
| const result = computeReleaseNotes(semver.parse("1.0.0")!, false, feed, latest) | ||
| expect(result).toEqual("") | ||
| }) | ||
|
|
||
| it("returns an array of release notes between currentVersion (exclusive) and latestVersion (inclusive), sorted desc", () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/v1.3.0"/> | ||
| <content>Notes v1.3.0</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.2.0"/> | ||
| <content>Notes 1.2.0</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/0.9.0"/> | ||
| <content>Notes 0.9.0</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/docs-update"/> | ||
| <content>Docs</content> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const entries = feed.getElements("entry") | ||
| const latest = entries[0] // v1.3.0 | ||
| const result = computeReleaseNotes(semver.parse("1.0.0")!, true, feed, latest) | ||
| expect(result).deep.equal([ | ||
| { version: "1.3.0", note: "Notes v1.3.0" }, | ||
| { version: "1.2.0", note: "Notes 1.2.0" }, | ||
| ]) | ||
| }) | ||
|
|
||
| it("returns null when latest release tag cannot be parsed to a version", () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/not-a-version"/> | ||
| <content>Latest with invalid tag</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.5.0"/> | ||
| <content>Should be ignored</content> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const latest = feed.element("entry") | ||
| const result = computeReleaseNotes(semver.parse("1.0.0")!, true, feed, latest) | ||
| expect(result).toEqual(null) | ||
| }) | ||
| }) | ||
|
|
||
| it("handles missing <content> element when full changelog is false", () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.0.1"/> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const latest = feed.element("entry") | ||
| const result = computeReleaseNotes(semver.parse("1.0.0")!, false, feed, latest) | ||
| expect(result).toEqual("") | ||
| }) | ||
|
|
||
| it("includes prerelease entries when they are > currentVersion and <= latestVersion", () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/v1.2.0"/> | ||
| <content>Release v1.2.0</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.2.0-beta.2"/> | ||
| <content>Beta notes</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.1.0"/> | ||
| <content>1.1.0 notes</content> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const latest = feed.getElements("entry")[0] | ||
| const result = computeReleaseNotes(semver.parse("1.0.0")!, true, feed, latest) as any[] | ||
| expect(result).deep.equal([ | ||
| { version: "1.2.0", note: "Release v1.2.0" }, | ||
| { version: "1.2.0-beta.2", note: "Beta notes" }, | ||
| { version: "1.1.0", note: "1.1.0 notes" }, | ||
| ]) | ||
| }) | ||
|
|
||
| it("excludes versions that are <= currentVersion", () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.2.0"/> | ||
| <content>1.2.0</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.1.5"/> | ||
| <content>1.1.5</content> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const latest = feed.element("entry") | ||
| const result = computeReleaseNotes(semver.parse("1.2.0")!, true, feed, latest) | ||
| expect(result).toEqual([]) | ||
| }) | ||
|
|
||
| it("supports tags with build metadata and sorts results correctly", () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/v1.3.0+build.1"/> | ||
| <content>1.3.0 build</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.2.5+exp.sha.5114f85"/> | ||
| <content>1.2.5 exp</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.3.0"/> | ||
| <content>latest</content> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const latest = feed.getElements("entry")[2] | ||
| const result = computeReleaseNotes(semver.parse("1.2.0")!, true, feed, latest) as any[] | ||
| expect(result).deep.equal([ | ||
| { version: "1.3.0+build.1", note: "1.3.0 build" }, | ||
| { version: "1.3.0", note: "latest" }, | ||
| { version: "1.2.5+exp.sha.5114f85", note: "1.2.5 exp" }, | ||
| ]) | ||
| }) | ||
|
|
||
| it("ignores entries whose link does not contain /tag/ (regex mismatch)", () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/1.4.0"/> | ||
| <content>Bad link</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.4.0"/> | ||
| <content>Good</content> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const latest = feed.getElements("entry")[1] | ||
| const result = computeReleaseNotes(semver.parse("1.3.0")!, true, feed, latest) as any[] | ||
| expect(result).deep.equal([{ version: "1.4.0", note: "Good" }]) | ||
| }) | ||
|
|
||
| it("includes entry that is equal to latestVersion (latest included)", () => { | ||
| const feed = parseXml(` | ||
| <feed> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/2.0.0"/> | ||
| <content>Latest notes</content> | ||
| </entry> | ||
| <entry> | ||
| <link href="https://github.com/owner/repo/releases/tag/1.9.0"/> | ||
| <content>1.9.0 notes</content> | ||
| </entry> | ||
| </feed> | ||
| `) | ||
| const latest = feed.element("entry") | ||
| const result = computeReleaseNotes(semver.parse("1.8.0")!, true, feed, latest) as any[] | ||
| expect(result).deep.equal([ | ||
| { version: "2.0.0", note: "Latest notes" }, | ||
| { version: "1.9.0", note: "1.9.0 notes" }, | ||
| ]) | ||
| }) | ||
| }) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.