GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: incorrect results from diff sometimes with prerelease versions by tjenkinson · Pull Request #546 · npm/node-semver

Conversation

@tjenkinson

@tjenkinson tjenkinson commented Apr 11, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

The following inputs previously gave the incorrect result based on my understanding:

  • 0.0.2-1 => 0.0.3 was prepatch when it should be patch, as it's doing a patch operation that goes from the first to the second. Fixed with first commit.
  • 0.0.0-1 => 0.0.0 was prerelease when it should be major. I think 0.0.0-1 => 0.0.0 should be consistent with 1.0.0-1 => 1.0.0. Fixed with second commit. This makes it more consistent but not sure if it's actually what people would expect. See below.
  • 1.0.0-1 => 2.0.0-1 was premajor but should be major because the biggest change is the major version. Fixed with third commit.

I'm actually not convinced the behaviour for the second point is correct. For any version change where the stable part remains the same and the prerelease gets removed, npm version patch would give that result. So should the diff always be patch for these cases?

I.e 1.1.0-pre => 1.1.0 is achievable with npm version patch and npm version minor. I personally would have expected the diff between those to be patch, just like it would be if it was 1.1.1-pre => 1.1.1

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tjenkinson added 3 commits April 11, 2023 11:05
@tjenkinson
fix: diff giving wrong result when going prerelease => stable
65b34a8
`0.0.2-1` => `0.0.3` should be `patch` not `prepatch`
@tjenkinson
fix: incorrect diff when going from 0.0.0 prerelease to 0.0.0
891b7da
@tjenkinson
fix: diff not pre* when stable part of 2 prereleases changes
f8c38e9
I.e. `1.0.0-1` => `2.0.0-1` should be `major` not `premajor`, because the biggest change is the major version
@tjenkinson
tjenkinson marked this pull request as ready for review April 11, 2023 22:37
@tjenkinson
tjenkinson requested a review from a team as a code owner April 11, 2023 22:37
@tjenkinson
tjenkinson requested a review from fritzy April 11, 2023 22:37
@tjenkinson
fix: refactor to remove level of nesting
2c37998
@tjenkinson tjenkinson mentioned this pull request Apr 11, 2023
Bump semver from 7.3.8 to 7.4.0 tjenkinson/gh-action-auto-merge-dependency-updates#576
Merged
@wraithgar
wraithgar requested review from wraithgar and removed request for fritzy April 12, 2023 21:47
wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread functions/diff.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@wraithgar

wraithgar commented Apr 12, 2023

Copy link
Copy Markdown
Contributor

Yeah I think the pre* diff results are very counterintuitive. They are trying to leverage the operations that .inc would do, but diff is not currently directional. Your PR attempts to make the comparison directional which is the part that would need to be discussed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tjenkinson
Merge branch 'main' into fix-diff-prerelease
f584c08
wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread functions/diff.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread test/functions/diff.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@wraithgar wraithgar changed the title Fix incorrect result from diff sometimes with prerelease versions fix: incorrect results from diff sometimes with prerelease versions Apr 12, 2023
@wraithgar
wraithgar requested a review from nlf April 12, 2023 22:08
@tjenkinson
add comment about prefix
89ae1fe
@wraithgar

wraithgar commented Apr 12, 2023

Copy link
Copy Markdown
Contributor

Gonna kind of spam those test lines w/ comments sorry for the noise but this deserves a good paper trail

tjenkinson reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread test/functions/diff.js
['1.0.0', '1.0.0', null],
['1.0.0-1', '1.0.0-1', null],
['0.0.2-1', '0.0.2', 'patch'],
['0.0.2-1', '0.0.3', 'patch'],

@wraithgar wraithgar Apr 12, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The difference is actually two .inc patches, but that's still a patch difference. A good test

> semver.inc('0.0.2-1', 'patch')
'0.0.2'
> semver.inc('0.0.2', 'patch')
'0.0.3'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread test/functions/diff.js
['1.0.0-1', '1.0.0-1', null],
['0.0.2-1', '0.0.2', 'patch'],
['0.0.2-1', '0.0.3', 'patch'],
['0.0.2-1', '0.1.0', 'minor'],

@wraithgar wraithgar Apr 12, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

> semver.inc('0.0.2-1', 'minor')
'0.1.0'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread test/functions/diff.js
['0.0.2-1', '0.0.2', 'patch'],
['0.0.2-1', '0.0.3', 'patch'],
['0.0.2-1', '0.1.0', 'minor'],
['0.0.2-1', '1.0.0', 'major'],

@wraithgar wraithgar Apr 12, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

> semver.inc('0.0.2-1', 'major')
'1.0.0'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread test/functions/diff.js
['1.1.0', '1.1.0-pre', 'minor'],
['1.1.0-pre-1', '1.1.0-pre-2', 'prerelease'],
['1.0.0', '1.0.0', null],
['1.0.0-1', '1.0.0-1', null],

@wraithgar wraithgar Apr 12, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

> semver.eq('1.0.0-1', '1.0.0-1')
true

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread test/functions/diff.js
['0.1.0-1', '0.1.0', 'minor'],
['1.0.0-1', '1.0.0', 'major'],
['0.0.0-1', '0.0.0', 'prerelease'],
['1.0.1-1', '1.0.1', 'patch'],

@wraithgar wraithgar Apr 12, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

> semver.inc('1.0.1-1', 'patch')
'1.0.1'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread test/functions/diff.js
['1.0.0-1', '1.0.0', 'major'],
['0.0.0-1', '0.0.0', 'prerelease'],
['1.0.1-1', '1.0.1', 'patch'],
['0.0.0-1', '0.0.0', 'major'],

@wraithgar wraithgar Apr 12, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

> semver.inc('0.0.0-1', 'major')
'0.0.0'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread test/functions/diff.js
['0.0.0-1', '0.0.0', 'prerelease'],
['1.0.1-1', '1.0.1', 'patch'],
['0.0.0-1', '0.0.0', 'major'],
['1.0.0-1', '2.0.0', 'major'],

@wraithgar wraithgar Apr 12, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Again this is two major .inc operations but that's still a major diff

> semver.inc('1.0.0-1', 'major')
'1.0.0'
> semver.inc('1.0.0', 'major')
'2.0.0'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
wraithgar
wraithgar reviewed Apr 12, 2023
View reviewed changes
Comment thread test/functions/diff.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@wraithgar

wraithgar commented Apr 12, 2023

Copy link
Copy Markdown
Contributor

1.0.0-1 => 2.0.0-1 was premajor but should be major because the biggest change is the major version. Fixed with third commit.

This still seems like premajor as per my comment on the test fixture:

> semver.inc('1.0.0', 'premajor')
'2.0.0-0'
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tjenkinson

tjenkinson commented Apr 12, 2023

Copy link
Copy Markdown
Contributor Author

Hmm yeh prerelease to prerelease on a different version is a bit confusing. Maybe prerelease to prerelease should also always be pre* ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tjenkinson

tjenkinson commented Apr 12, 2023

Copy link
Copy Markdown
Contributor Author

Is the definition of pre* meant to be ‘going to a prerelease version’? If that’s the case those 3 tests should be pre*

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ms-bot ms-bot mentioned this pull request Jun 5, 2023
chore(deps): bump 🧳 semver to ^7.6.3 mobsuccess-devops/pmd-github-action#11
Closed
This was referenced Jul 31, 2023
Bump semver from 7.3.5 to 7.5.2 in /platform/ui ossrs/oryx#107
Closed
Bump semver from 7.3.5 to 7.5.4 in /platform/ui ossrs/oryx#111
Closed
Bump semver from 7.3.5 to 7.5.2 in /ui ossrs/oryx#116
Closed
@wraithgar wraithgar mentioned this pull request Oct 18, 2023
fix: correctly increase version for "pre" versions #643
Closed
@wraithgar wraithgar mentioned this pull request Jan 8, 2024
[BUG] diff prerelease changed between 7.3.8 and 7.5.4 #607
Closed
1 task done
This was referenced May 24, 2024
[Snyk] Upgrade semver from 7.3.7 to 7.6.0 NOUIY/npm-groovy-lint#71
Closed
[Snyk] Upgrade semver from 7.3.8 to 7.6.0 NOUIY/security-wg#55
Closed
@devcurt696 devcurt696 mentioned this pull request May 29, 2024
[Snyk] Upgrade semver from 7.0.0 to 7.6.1 devcurt696/resume-builder#77
Open
@NOUIY NOUIY mentioned this pull request May 30, 2024
[Snyk] Upgrade semver from 7.3.7 to 7.6.1 NOUIY/npm-groovy-lint#77
Closed
@fanibahar fanibahar mentioned this pull request May 30, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 fanibahar/juice-shop1#71
Open
@devcurt696 devcurt696 mentioned this pull request May 31, 2024
[Snyk] Upgrade semver from 7.0.0 to 7.6.2 devcurt696/resume-builder#78
Open
@NOUIY NOUIY mentioned this pull request May 31, 2024
[Snyk] Upgrade semver from 7.3.7 to 7.6.2 NOUIY/npm-groovy-lint#78
Closed
@Mhmonicox Mhmonicox mentioned this pull request Jun 1, 2024
[Snyk] Upgrade semver from 7.3.6 to 7.6.2 Mhmonicox/actions-setup-cmake#35
Open
@Haricthered Haricthered mentioned this pull request Jun 7, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Haricthered/juice-shop#5
Open
@AndrewSnyk AndrewSnyk mentioned this pull request Jun 8, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 AndrewSnyk/juice-shop#5
Merged
@jessicazhanggg jessicazhanggg mentioned this pull request Jun 13, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 jessicazhanggg/juice-shop#6
Open
@monjie110 monjie110 mentioned this pull request Jun 22, 2024
[Snyk] Upgrade semver from 7.3.4 to 7.6.2 monjie110/vscode-go#4
Open
@Kavinpg96 Kavinpg96 mentioned this pull request Jun 25, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Kavinpg96/nodejs.org#5
Open
@dulumina dulumina mentioned this pull request Jul 11, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 dulumina/WBOT#2
Open
This was referenced Jul 16, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Exhorder6/addons-linter#31
Closed
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 terrorizer1980/addons-linter#35
Closed
@Z-byte-prog Z-byte-prog mentioned this pull request Jul 17, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Z-byte-prog/docs#1243
Closed
@safiaminnn safiaminnn mentioned this pull request Jul 21, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 safiaminnn/juice-shop#5
Open
@YoYBaBy YoYBaBy mentioned this pull request Jul 23, 2024
[Snyk] Upgrade semver from 7.3.2 to 7.6.2 YoYBaBy/nodejs.org#274
Open
@koishichito koishichito mentioned this pull request Jul 24, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 koishichito/juice-shop#5
Open
@KobayashiMasaomi KobayashiMasaomi mentioned this pull request Jul 25, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 KobayashiMasaomi/juice-shop#10
Open
@q1blue q1blue mentioned this pull request Jul 28, 2024
[Snyk] Upgrade semver from 5.7.2 to 7.6.2 https-quantumblockchainai-atlassian-net/botframework-sdk#1
Open
@otmaneEH otmaneEH mentioned this pull request Jul 30, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 otmaneEH/docs#4
Open
@annkornienko annkornienko mentioned this pull request Jul 30, 2024
[Snyk] Upgrade semver from 7.3.5 to 7.6.2 Simpplr/serverless-plugin-include-dependencies#12
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

2 more reviewers
@wraithgar wraithgar wraithgar approved these changes
@nlf nlf nlf approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@tjenkinson @wraithgar @nlf
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.