-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Consistent version formatting #1246
Changes from 1 commit
fa4be71
1846d44
1839b16
d454992
6236719
cf1b7d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,14 +63,15 @@ function omitv(version) { | |
return version; | ||
} | ||
|
||
// Add a starting v to the version number if needed. | ||
const ignoredVersionPatterns = /^[^0-9]+|[0-9]{4}-[0-9]{2}-[0-9]{2}/; | ||
// Add a starting v to the version unless: | ||
// - it does not start with a digit | ||
// - it is a date (yyyy-mm-dd) | ||
const ignoredVersionPatterns = /^[^0-9]|[0-9]{4}-[0-9]{2}-[0-9]{2}/; | ||
function addv(version) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double negatives are hard to understand, so when it's possible to rewrite an
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I should have been more clever than just copy pasting the leftovers of the old function. ^^ |
||
const first = version[0]; | ||
if (first !== 'v' && !ignoredVersionPatterns.test(version)) { | ||
return 'v' + version; | ||
} else { | ||
if (version.startsWith('v') || ignoredVersionPatterns.test(version)) { | ||
return version; | ||
} else { | ||
return `v${version}`; | ||
} | ||
} | ||
|
||
|
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.
👍