elgg-conventional-changelog
Advanced tools
Comparing version 0.1.0 to 0.1.1
14
index.js
@@ -22,15 +22,15 @@ | ||
git.latestTag(function(err, tag) { | ||
if (err || !tag) return done('Failed to read git tags.\n'+err); | ||
writeChangelog(tag); | ||
git.getTags(function(err, tags) { | ||
if (err || !tags) return done('Failed to read git tags.\n'+err); | ||
writeChangelog(tags); | ||
}); | ||
function writeChangelog(latestTag) { | ||
options.from = options.from || latestTag; | ||
function writeChangelog(tags) { | ||
options.exclude = options.exclude || tags; | ||
options.to = options.to || 'HEAD'; | ||
options.log('Generating changelog from %s to %s...', options.from, options.to); | ||
options.log('Generating changelog for %s...', options.version); | ||
git.getLog({ | ||
from: options.from, | ||
exclude: options.exclude, | ||
to: options.to, | ||
@@ -37,0 +37,0 @@ }, function(err, gitLog) { |
@@ -8,3 +8,3 @@ var extend = require('lodash.assign'); | ||
getLog: getLog, | ||
latestTag: latestTag | ||
getTags: getTags | ||
}; | ||
@@ -31,24 +31,9 @@ | ||
//Get latest tag, or if no tag first commit | ||
function latestTag(done) { | ||
function getTags(done) { | ||
//Get tags sorted by date | ||
cp.exec("git describe --tags `git rev-list --tags --max-count=1`", function(err, stdout, stderr) { | ||
if (err) { | ||
getFirstCommit(done); | ||
} else { | ||
done(null, String(stdout).trim()); | ||
} | ||
cp.exec("git tag", function(err, stdout, stderr) { | ||
done(null, String(stdout).trim().split('\n')); | ||
}); | ||
} | ||
function getFirstCommit(done) { | ||
//Error --> no tag, get first commit | ||
cp.exec('git log --format="%H" --pretty=oneline --reverse', function(err, stdout, stderr) { | ||
if (stderr || !String(stdout).trim()) { | ||
done('No commits found!'); | ||
} else { | ||
done(null, String(stdout).split('\n')[0].split(' ')[0].trim()); | ||
} | ||
}); | ||
} | ||
function filterExists(data, cb) { | ||
@@ -62,10 +47,13 @@ if (data) cb(null, data); | ||
options = extend({ | ||
from: '', | ||
exclude: [], | ||
to: 'HEAD' | ||
}, options || {}); | ||
var cmd = 'git shortlog -sne %s --no-merges'; | ||
var cmd = 'git shortlog -sne %s --no-merges %s'; | ||
cmd = util.format( | ||
cmd, | ||
options.from ? options.from + '..' + options.to : '' | ||
options.to, | ||
options.exclude.map(function(tag) { | ||
return "^" + tag; | ||
}).join(' ') | ||
); | ||
@@ -104,7 +92,7 @@ | ||
format: '%H%n%s%n%b%n==END==', | ||
from: '', | ||
exclude: [], | ||
to: 'HEAD' | ||
}, options || {}); | ||
var cmd = 'git log --grep="%s" -E --format=%s %s'; | ||
var cmd = 'git log --grep="%s" -E --format=%s %s %s'; | ||
cmd = util.format( | ||
@@ -114,3 +102,6 @@ cmd, | ||
options.format, | ||
options.from ? options.from+'..'+options.to : '' | ||
options.to, | ||
options.exclude.map(function(tag) { | ||
return "^" + tag; | ||
}).join(' ') | ||
); | ||
@@ -117,0 +108,0 @@ |
{ | ||
"name": "elgg-conventional-changelog", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Generate a markdown changelog from git commit metadata", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
19537
474