Skip to content

Commit

Permalink
fix(diff): fix prerelease to stable version diff logic
Browse files Browse the repository at this point in the history
Refactored version diff logic to handle transitions from prerelease versions
to stable versions correctly for major/minor/patch version bumps.
  • Loading branch information
berkay.daglar committed Jan 21, 2025
1 parent 868d4bb commit c43566b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions functions/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ const diff = (version1, version2) => {

// Otherwise it can be determined by checking the high version

if (highVersion.patch) {
// anything higher than a patch bump would result in the wrong version
return 'patch'
}

if (highVersion.minor) {
// anything higher than a minor bump would result in the wrong version
return 'minor'
}

if (highVersion.patch) {
// anything higher than a patch bump would result in the wrong version
return 'patch'
}

// bumping major/minor/patch all have same result
return 'major'
}
Expand Down
1 change: 1 addition & 0 deletions test/functions/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ test('diff versions test', (t) => {
['1.0.0-1', '2.0.0-1', 'premajor'],
['1.0.0-1', '1.1.0-1', 'preminor'],
['1.0.0-1', '1.0.1-1', 'prepatch'],
['1.7.2-1', '1.8.1', 'minor'],
].forEach((v) => {
const version1 = v[0]
const version2 = v[1]
Expand Down

0 comments on commit c43566b

Please sign in to comment.