-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fixes issue 42 and 94. #125
Changes from all commits
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 |
---|---|---|
|
@@ -6,6 +6,10 @@ | |
* grunt bump:patch | ||
* grunt bump:minor | ||
* grunt bump:major | ||
* grunt bump:prepatch | ||
* grunt bump:preminor | ||
* grunt bump:premajor | ||
* grunt bump:prerelease | ||
* | ||
* @author Vojta Jina <[email protected]> | ||
* @author Mathias Paumgarten <[email protected]> | ||
|
@@ -34,7 +38,8 @@ module.exports = function(grunt) { | |
push: true, | ||
pushTo: 'upstream', | ||
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d', | ||
globalReplace: false | ||
globalReplace: false, | ||
prereleaseName: null | ||
}); | ||
|
||
var dryRun = grunt.option('dry-run'); | ||
|
@@ -77,14 +82,12 @@ module.exports = function(grunt) { | |
|
||
var globalVersion; // when bumping multiple files | ||
var gitVersion; // when bumping using `git describe` | ||
var VERSION_REGEXP = /([\'|\"]?version[\'|\"]?[ ]*:[ ]*[\'|\"]?)([\d||A-a|.|-]*)([\'|\"]?)/i; | ||
|
||
var VERSION_REGEXP = new RegExp('([\\\'|\\\"]?version[\\\'|\\\"]?[ ]*:[ ]*[\\\'|\\\"]?)(\\\d+\\\.\\\d+\\\.\\\d+(-'+opts.prereleaseName+'\\\.\\\d+)?(-\\\d+)?)[\\\d||A-a|.|-]*([\\\'|\\\"]?)', 'i'); | ||
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. holy smokes batman, that is one scary regex 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. If you get rid of all the escapes (that are there so we can add a variable) it's much less scary looking. I tried to write a couple of tests, but am unfamiliar with testing node modules. 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. didnt notice this before, but shouldn't the regex replace:
with something that won't translate to:
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. @schechter ^^ 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. I don't think so. |
||
|
||
if (opts.globalReplace) { | ||
VERSION_REGEXP = new RegExp(VERSION_REGEXP.source, 'gi'); | ||
} | ||
|
||
|
||
// GET VERSION FROM GIT | ||
runIf(opts.bumpVersion && versionType === 'git', function() { | ||
exec('git describe ' + opts.gitDescribeOptions, function(err, stdout) { | ||
|
@@ -96,14 +99,13 @@ module.exports = function(grunt) { | |
}); | ||
}); | ||
|
||
|
||
// BUMP ALL FILES | ||
runIf(opts.bumpVersion, function() { | ||
grunt.file.expand(opts.files).forEach(function(file, idx) { | ||
var version = null; | ||
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. This part got left off so bump:git isn't working. #129 Working on fixing it. |
||
var content = grunt.file.read(file).replace(VERSION_REGEXP, function(match, prefix, parsedVersion, suffix) { | ||
gitVersion = gitVersion && parsedVersion + '-' + gitVersion; | ||
version = exactVersionToSet || gitVersion || semver.inc(parsedVersion, versionType || 'patch'); | ||
var bumpFrom; | ||
var content = grunt.file.read(file).replace(VERSION_REGEXP, function(match, prefix, parsedVersion, namedPre, noNamePre, suffix) { | ||
version = exactVersionToSet || gitVersion || semver.inc(parsedVersion, versionType || 'patch', opts.prereleaseName); | ||
return prefix + version + suffix; | ||
}); | ||
|
||
|
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.
these examples are a little confusing. why go from prepatch to prerelease?
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.
re: examples/ expected behavior of prerelease
bump:prerelease is how you bump the prerelease version.
From a released version (1.0.0) you choose
The way it is now (and in the readme) is incorrect.
1.0.0-1 should be the prerelease for 1.0.0 so this should not be the expected behavior.
re: the defaulted prreleaeName.
There needs to be something other than an empty string as the prereleaseName otherwise the the versions are not bumped properly. They behave more like he existing functionality of prerelease which is incorrect.
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.
From Semver 2.0.0:
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.
You missed:
Meaning everything after the hyphen is the identifier. To have multiple identifiers, you separate them with dots.
As for the current current behavior of going from
1.0.0
to1.0.0-1
as the next prerelease, that is a bug that existed in semver which has since been fixed. Purely upgrading semver with no other changes would make it go from1.0.0
to1.0.1-0
.