Skip to content
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

Incorrect Increment for versions < 1.0 #177

Closed
tleunen opened this issue Nov 13, 2016 · 2 comments
Closed

Incorrect Increment for versions < 1.0 #177

tleunen opened this issue Nov 13, 2016 · 2 comments

Comments

@tleunen
Copy link

tleunen commented Nov 13, 2016

Given a version x.y.z, when x is 0, y should be incremented for a major version, and z for minor and patch. But the current version of semver treats a 0.x.y the same way as 1.x.y.

const semver = require("semver");
semver.inc('0.1.0', 'major');

gives 1.0.0 instead of 0.2.0

@brokenmass
Copy link

brokenmass commented Nov 28, 2016

I don't agree.
how will you be able to move from a 0.x to 1.0 version then ?
and what would you expect semver.major(0.2.0) to return ?
I expect that (semver.major(x) + 1) === semver.major(semver.inc(x, 'major'))

it's your code that should take responsibility of handling the special 0.x case as the first number is always the identifier of major and the fact that semver allos you to use, in version 0.x, bump in minor to handle breaking changes is irrelevant.
your code should be able to handle the logic and do something like (example of a semantic version bump):

if (semver.major(myVersion) === 0) {
  myNewVersion = semver.inc(myCurrentVersion, isBreakingChange(commit) ? 'minor' : 'patch');
} else {
  if(isBreakingChange(commit)) {
    myNewVersion = semver.inc('major');
  } else if (isNewFeature(commit)) {
    myNewVersion = semver.inc('minor');
  } else {
    myNewVersion = semver.inc('patch');
  }
}

@isaacs
Copy link
Contributor

isaacs commented Nov 28, 2016

This is working as designed. The technical term for the first number in the tuple is "major".

If you want to increment the minor version for a breaking change, then that's your call, and the semver specification is ambivalent about doing so in a 0.x version. But the terms are still "major, minor, patch", regardless of whether the major version is 0.

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

No branches or pull requests

3 participants