grunt-changelog-customizable
Advanced tools
Comparing version 0.3.4 to 0.4.0
@@ -38,2 +38,3 @@ /* | ||
options: { | ||
end: 'v0.3.0', | ||
type: 'all', | ||
@@ -40,0 +41,0 @@ template: '{{> features}}{{> fixes}}', |
{ | ||
"name": "grunt-changelog-customizable", | ||
"description": "A grunt task to generate changelog from git repository.", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"homepage": "https://github.com/wallet77/grunt-changelog-customizable", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -46,2 +46,3 @@ # grunt-changelog-customizable | ||
A string value that is a date or a git tag | ||
In case of git tag and if options.start is empty then get previous tag as options.start | ||
@@ -52,3 +53,7 @@ #### options.start | ||
A string value that is a date or a git tag | ||
A string value that is a date or a git tag. | ||
Can be empty if options.end is a git tag. In that case previous git tag will be used as start value. | ||
```shell | ||
git describe --abbrev=0 tagname^ | ||
``` | ||
@@ -55,0 +60,0 @@ #### options.header |
@@ -68,5 +68,5 @@ /* | ||
// ------------------------------------------------------------------------------ | ||
if (options.start) { | ||
if (options.end || options.start) { | ||
if (!semver.valid(options.start)) { | ||
if (!semver.valid(options.end)) { | ||
start = moment(options.start); | ||
@@ -77,8 +77,5 @@ if(!start.isValid()) { | ||
if(options.end) { | ||
end = moment(options.end); | ||
if(!end.isValid()) { | ||
end = moment(); // until now | ||
} | ||
end = moment(options.end); | ||
if(!end.isValid()) { | ||
end = moment(); // until now | ||
} | ||
@@ -91,9 +88,7 @@ | ||
} else { | ||
start = options.start; | ||
end = semver.valid(options.end) ? options.end : null; | ||
end = options.end; | ||
start = options.start && semver.valid(options.start) ? options.start : null; | ||
} | ||
} | ||
if(!start) { | ||
} else { | ||
start = moment().subtract(14, 'days').format(); // basic scrum sprint | ||
@@ -124,3 +119,2 @@ end = moment().format(); | ||
// ------------------------------------------------------------------------------ | ||
@@ -135,48 +129,46 @@ // Git command | ||
if (options.logArguments) { | ||
args.push.apply(args, options.logArguments); | ||
} else { | ||
args.push( | ||
'--format=%B', | ||
'--no-merges' | ||
); | ||
} | ||
// if we have a git tag for end but nothing into start | ||
// then we can get previous tag | ||
if(!isDate && !start) { | ||
grunt.util.spawn( | ||
{ | ||
cmd: 'git', | ||
args: ['pull', '--tags'] | ||
}, | ||
// git with date | ||
if (isDate) { | ||
args.push('--after="' + start + '"'); | ||
args.push('--before="' + end + '"'); | ||
} else { // git with tag | ||
args.splice(2, 0, start + '..' + end); | ||
} | ||
function (error, result) { | ||
grunt.verbose.writeln('git ' + args.join(' ')); | ||
if (error) { | ||
grunt.log.error(error); | ||
return done(false); | ||
} | ||
grunt.util.spawn( | ||
{ | ||
cmd: 'git', | ||
args: args | ||
}, | ||
function (error, result) { | ||
if (error) { | ||
grunt.log.error(error); | ||
return done(false); | ||
} | ||
grunt.util.spawn( | ||
{ | ||
cmd: 'git', | ||
args: ['describe', '--abbrev=0', end + '^'] | ||
}, | ||
var templateData = utils.getTemplateData(result, options), | ||
changeLog; | ||
function (error, result) { | ||
if (error) { | ||
grunt.log.error(error); | ||
return done(false); | ||
} | ||
for(var key in templateData) { | ||
changeLog = compiledGlobalTemplate(templateData[key]); | ||
utils.writeChangeLogFile(options, grunt, key, changeLog); | ||
start = result; | ||
utils.launchGitLog(grunt, options, args, isDate, start, end, compiledGlobalTemplate, done); | ||
} | ||
); | ||
} | ||
); | ||
} else { | ||
utils.launchGitLog(grunt, options, args, isDate, start, end, compiledGlobalTemplate, done); | ||
} | ||
done(); | ||
} | ||
); | ||
}); | ||
}; |
@@ -133,2 +133,51 @@ 'use strict'; | ||
Utils.prototype.launchGitLog = function(grunt, options, args, isDate, start, end, compiledGlobalTemplate, done) { | ||
var self = this; | ||
if (options.logArguments) { | ||
args.push.apply(args, options.logArguments); | ||
} else { | ||
args.push( | ||
'--format=%B', | ||
'--no-merges' | ||
); | ||
} | ||
// git with date | ||
if (isDate) { | ||
args.push('--after="' + start + '"'); | ||
args.push('--before="' + end + '"'); | ||
} else { // git with tag | ||
args.splice(2, 0, start + '..' + end); | ||
} | ||
grunt.log.writeln('git ' + args.join(' ')); | ||
grunt.util.spawn( | ||
{ | ||
cmd: 'git', | ||
args: args | ||
}, | ||
function (error, result) { | ||
if (error) { | ||
grunt.log.error(error); | ||
return done(false); | ||
} | ||
var templateData = self.getTemplateData(result, options), | ||
changeLog; | ||
for (var key in templateData) { | ||
changeLog = compiledGlobalTemplate(templateData[key]); | ||
self.writeChangeLogFile(options, grunt, key, changeLog); | ||
} | ||
done(); | ||
} | ||
); | ||
}; | ||
module.exports = new Utils(); |
@@ -0,0 +0,0 @@ 'use strict'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58369
14
386
179