Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: diff not pre* when stable part of 2 prereleases changes
I.e. `1.0.0-1` => `2.0.0-1` should be `major` not `premajor`, because the biggest change is the major version
  • Loading branch information
tjenkinson committed Apr 11, 2023
commit f8c38e9b965a0289c9ce9f07891ee2ed7ef3a514
2 changes: 1 addition & 1 deletion functions/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const diff = (version1, version2) => {
const lowVersion = v1Higher ? v2 : v1
const highHasPre = !!highVersion.prerelease.length
const lowHasPre = !!lowVersion.prerelease.length
const prefix = highHasPre ? 'pre' : ''
const prefix = highHasPre && !lowHasPre ? 'pre' : ''
Comment thread
wraithgar marked this conversation as resolved.
Outdated

if (v1.major !== v2.major) {
return prefix + 'major'
Expand Down
3 changes: 3 additions & 0 deletions test/functions/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ test('diff versions test', (t) => {
['1.0.1-1', '1.0.1', 'patch'],

Copy link
Copy Markdown
Contributor

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'

['0.0.0-1', '0.0.0', 'major'],

Copy link
Copy Markdown
Contributor

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'

['1.0.0-1', '2.0.0', 'major'],

Copy link
Copy Markdown
Contributor

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'

['1.0.0-1', '2.0.0-1', 'major'],
['1.0.0-1', '1.1.0-1', 'minor'],
['1.0.0-1', '1.0.1-1', 'patch'],
Comment thread
wraithgar marked this conversation as resolved.
Outdated
].forEach((v) => {
const version1 = v[0]
const version2 = v[1]
Expand Down