git-conventional-commits
Advanced tools
Comparing version 1.0.10 to 1.1.0
@@ -18,3 +18,3 @@ { | ||
"commitScopes": [], | ||
"releaseTagGlobPattern": "v[0-9]*.[0-9]*.[0-9]*", | ||
"releaseTagGlobPattern": "v[0-9].*", | ||
"issueRegexPattern": "(^|\\s)#\\d+(\\s|$)" | ||
@@ -21,0 +21,0 @@ }, |
@@ -15,2 +15,7 @@ const Config = require("./config"); | ||
}) | ||
yargs.option('commit', { | ||
desc: 'Commit anchor e.g. v1.0.0', | ||
default: 'HEAD', | ||
requiresArg: true | ||
}) | ||
@@ -45,13 +50,12 @@ yargs.option('release', { | ||
const config = Config.load(argv.config); | ||
const commitConvention = new CommitConvention(config.convention); | ||
const commitConvention = new CommitConvention(config.convention, argv.commit); | ||
const changelogGenerator = new ChangelogGenerator(config.changelog); | ||
const conventionalCommits = await commitConvention.commitLog(); | ||
let releaseName = argv.release || await commitConvention.version(conventionalCommits); | ||
let releaseName = argv.release || await commitConvention.version(); | ||
if (argv.name) { | ||
releaseName += ` - ${argv.name}`; | ||
} | ||
const changelogCommits = conventionalCommits | ||
const commitLog = await commitConvention.commitLog(); | ||
const changelogCommits = commitLog | ||
.filter( // filter by commit messages regex | ||
@@ -69,4 +73,4 @@ commit => ![commit.subject, commit.body].join("\n\n").match(config.changelog.commitIgnoreRegex())) | ||
// ------ generate markdown -------------------------------------- | ||
let firstChangelogCommit = conventionalCommits[0].hash; | ||
let lastChangelogCommit = conventionalCommits.slice(-1)[0].hash; | ||
let firstChangelogCommit = commitLog[0].hash; | ||
let lastChangelogCommit = commitLog.slice(-1)[0].hash; | ||
let changelogMarkdown = changelogGenerator.generateMarkdown( | ||
@@ -73,0 +77,0 @@ firstChangelogCommit, lastChangelogCommit, |
@@ -13,2 +13,7 @@ const Config = require("./config"); | ||
}) | ||
yargs.option('commit', { | ||
desc: 'Commit anchor e.g. v1.0.0', | ||
default: 'HEAD', | ||
requiresArg: true | ||
}) | ||
} | ||
@@ -18,9 +23,7 @@ | ||
const config = Config.load(argv.config); | ||
const commitConvention = new CommitConvention(config.convention); | ||
const commitConvention = new CommitConvention(config.convention, argv.commit); | ||
const conventionalCommits = await commitConvention.commitLog(); | ||
const conventionalVersion = await commitConvention.version(); | ||
const conventionalVersion = await commitConvention.version(conventionalCommits); | ||
console.log(conventionalVersion); | ||
} |
const Git = require("./git"); | ||
module.exports = function(convention) { | ||
module.exports = function(convention, commitAnchor = 'HEAD') { | ||
let lastTag | ||
let commitLog | ||
async function getLastReleaseTag() { | ||
return await Git.lastTag(convention.releaseTagGlobPattern); | ||
if(lastTag === undefined){ | ||
lastTag = await Git.lastTag(convention.releaseTagGlobPattern, commitAnchor) | ||
} | ||
return lastTag | ||
} | ||
async function getCommitLog() { | ||
const lastReleaseTag = await getLastReleaseTag(); | ||
const commits = await Git.commitLog(lastReleaseTag); | ||
return commits.map(parseCommit); | ||
if(commitLog === undefined){ | ||
const lastReleaseTag = await getLastReleaseTag() | ||
const commits = await Git.commitLog(lastReleaseTag, commitAnchor); | ||
commitLog = commits.map(parseCommit); | ||
} | ||
return commitLog | ||
} | ||
async function getVersion(conventionalCommits) { | ||
async function getVersion() { | ||
const version = { | ||
@@ -40,3 +49,4 @@ major: 0, | ||
}; | ||
conventionalCommits.forEach(commit => { | ||
(await getCommitLog()).forEach(commit => { | ||
if (commit.breakingChanges && commit.breakingChanges.length) { | ||
@@ -43,0 +53,0 @@ changes.breaking++; |
{ | ||
"name": "git-conventional-commits", | ||
"version": "1.0.10", | ||
"version": "1.1.0", | ||
"description": "git conventional commits util", | ||
@@ -5,0 +5,0 @@ "licence": "MIT", |
29573
614