Skip to content

Update notifier: avoid false positives when gh is built from source#2812

Merged
mislav merged 1 commit intotrunkfrom
updater-dev-version-match
Jan 21, 2021
Merged

Update notifier: avoid false positives when gh is built from source#2812
mislav merged 1 commit intotrunkfrom
updater-dev-version-match

Conversation

@mislav
Copy link
Contributor

@mislav mislav commented Jan 20, 2021

When gh was built from source, the version number will look something like this since it's taken from git describe:

v1.4.0-34-g{SHA}

When compared as semver against v1.4.0, the latter version is falsely reported as newer. This is because the output of git describe wasn't meant to be interpreted as semver.

The solution is to translate the git describe string to faux-semver so it can be safely compared with the version reported from the server.

Fixes this case:

A new release of gh is available: v1.4.0-41-g2f9e4cb1 → v1.4.0
https://github.com/cli/cli/releases/tag/v1.4.0

When gh was built from source, the version number will look something
like this since it's taken from `git describe`:

    v1.4.0-34-g{SHA}

When compared as semver against `v1.4.0`, the latter version is falsely
reported as newer. This is because the output of `git describe` wasn't
meant to be interpreted as semver.

The solution is to translate the `git describe` string to faux-semver so
it can be safely compared with the version reported from the server.

Fixes this case:

    A new release of gh is available: v1.4.0-41-g2f9e4cb1 → v1.4.0
    https://github.com/cli/cli/releases/tag/v1.4.0
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

@mislav mislav merged commit f1a9da4 into trunk Jan 21, 2021
@mislav mislav deleted the updater-dev-version-match branch January 21, 2021 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants