-
Notifications
You must be signed in to change notification settings - Fork 513
[BUG] 7.6.0 --> 7.7.0 inc behavior change #763
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
Comments
Looks like there's something unexpected going on w/ our regexes. Both the Semver class constructor and constructor: const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
if (!m) {
throw new TypeError(`Invalid Version: ${version}`)
} inc: // Avoid an invalid semver results
if (identifier) {
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])
if (!match || match[1] !== identifier) {
throw new Error(`invalid identifier: ${identifier}`)
}
} regex: createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
}${src[t.PRERELEASE]}?${
src[t.BUILD]}?`)
createToken('FULL', `^${src[t.FULLPLAIN]}$`)
regex is doing something unexpected here.
|
> '-1a'.match(/(?:-((?:0|[1-9]\d{0,256}|\d{0,256}[a-zA-Z-][a-zA-Z0-9-]{0,250})(?:\.(?:0|[1-9]\d{0,256}|\d{0,256}[a-zA-Z-][a-zA-Z0-9-]{0,250}))*))?/)
[ '-1', '1', index: 0, input: '-1a', groups: undefined ]
> '1.0.0-1a'.match(/^v?(0|[1-9]\d{0,256})\.(0|[1-9]\d{0,256})\.(0|[1-9]\d{0,256})(?:-((?:0|[1-9]\d{0,256}|\d{0,256}[a-zA-Z-][a-zA-Z0-9-]{0,250})(?:\.(?:0|[1-9]\d{0,256}|\d{0,256}[a-zA-Z-][a-zA-Z0-9-]{0,250}))*))?(?:\+([a-zA-Z0-9-]{1,250}(?:\.[a-zA-Z0-9-]{1,250})*))?$/)
[
'1.0.0-1a',
'1',
'0',
'0',
'1a',
undefined,
index: 0,
input: '1.0.0-1a',
groups: undefined
] |
Solved: the > '-1a'.match(/(?:-((?:0|[1-9]\d{0,256}|\d{0,256}[a-zA-Z-][a-zA-Z0-9-]{0,250})(?:\.(?:0|[1-9]\d{0,256}|\d{0,256}[a-zA-Z-][a-zA-Z0-9-]{0,250}))*))?/)
[ '-1', '1', index: 0, input: '-1a', groups: undefined ]
> '-1a'.match(/^(?:-((?:0|[1-9]\d{0,256}|\d{0,256}[a-zA-Z-][a-zA-Z0-9-]{0,250})(?:\.(?:0|[1-9]\d{0,256}|\d{0,256}[a-zA-Z-][a-zA-Z0-9-]{0,250}))*))?$/)
[ '-1a', '1a', index: 0, input: '-1a', groups: undefined ] PR incoming |
Thank you @wraithgar! |
Is there an existing issue for this?
Current Behavior
We use auto in our CI to manage our versioning.
For canary releases, Auto uses a version format of
<version>-canary.<pr#>.<hash>
We started to see our CI randomly failing (based on commit hash or build hash) the last few days with the following error:
After digging deep into Lerna / Auto, I found out the root cause was due to a change of the semver package between 7.6.0 and 7.7.0
semver.inc('1.0.0', 'prepatch', 'canary.661.2207bf')
semver.valid('1.0.1-canary.661.2207bf.0')
1.0.1-canary.661.2207bf.0
1.0.1-canary.661.2207bf.0
null
1.0.1-canary.661.2207bf.0
Expected Behavior
I would expect
semver.inc('1.0.0', 'prepatch', 'canary.661.2207bf')
to continue to return a valid value orsemver.valid('1.0.1-canary.661.2207bf.0')
to returnnull
Steps To Reproduce
npm i semver@7.6.0 --save-exact node -e "console.log(require('semver').inc('1.0.0', 'prepatch', 'canary.661.2207bf'));"
npm i semver@7.7.0 --save-exact node -e "console.log(require('semver').inc('1.0.0', 'prepatch', 'canary.661.2207bf'));"
npm i semver@7.7.0 --save-exact node -e "console.log(require('semver').valid('1.0.1-canary.661.2207bf.0'));"
Environment
The text was updated successfully, but these errors were encountered: