git-conventional-commits
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -29,2 +29,3 @@ { | ||
], | ||
"includeInvalidCommits": true, | ||
"commitIgnoreRegexPattern": "^WIP ", | ||
@@ -31,0 +32,0 @@ "headlines": { |
@@ -62,4 +62,6 @@ const Config = require("./config"); | ||
.filter(// filter by commit type | ||
commit => !commit.type || !config.changelog.commitTypes || !config.changelog.commitTypes.length | ||
|| config.changelog.commitTypes.includes(commit.type)) | ||
commit => (!commit.type && config.changelog.includeInvalidCommits) // undefined commit type | ||
|| !config.changelog.commitTypes || !config.changelog.commitTypes.length // no filter at all | ||
|| (commit.type!==undefined && config.changelog.commitTypes.includes(commit.type)) // commit type in filter list | ||
) | ||
.filter( // filter by commit scope | ||
@@ -66,0 +68,0 @@ commit => !commit.scope || !config.changelog.commitScopes || !config.changelog.commitScopes.length |
@@ -30,2 +30,5 @@ const fs = require("fs"); | ||
changelogConfig.commitTypes = changelogOverride.commitTypes || changelogConfig.commitTypes; | ||
changelogConfig.includeInvalidCommits = changelogOverride.includeInvalidCommits !== undefined | ||
? changelogOverride.includeInvalidCommits === true | ||
: changelogConfig.includeInvalidCommits; | ||
changelogConfig.commitScopes = changelogOverride.commitScopes || changelogConfig.commitScopes; | ||
@@ -56,2 +59,3 @@ changelogConfig.commitIgnoreRegexPattern = changelogOverride.commitIgnoreRegexPattern || changelogConfig.commitIgnoreRegexPattern; | ||
commitTypes: ['feat', 'fix'], | ||
includeInvalidCommits: true, | ||
commitScopes: null, | ||
@@ -58,0 +62,0 @@ commitIgnoreRegexPattern: null, |
@@ -1,8 +0,7 @@ | ||
const execa = require('execa'); | ||
const execAsync = require('./execAsync'); | ||
async function getLastTag(tagGlobPattern, rev = 'HEAD', skipTagOnRev = true) { | ||
const lastTag = await execa('git', | ||
['describe', '--tags', `--match=${tagGlobPattern}`, '--first-parent', '--no-abbrev', rev]) | ||
.then(result => result.stdout) | ||
const lastTag = await execAsync(`git describe --tags --match=${tagGlobPattern} --first-parent --no-abbrev ${rev}`, {encoding: 'UTF-8'}) | ||
.then(result => result.trim()) | ||
.catch(err => { | ||
@@ -28,6 +27,6 @@ // return undefined if no tag was found | ||
const gitLogFormat = ["%h", "%s", "%b"].join(LOG_FIELD_SEPARATOR) + LOG_COMMIT_DELIMITER; | ||
const gitLog = await execa('git', ['log', '--reverse', `--format=${gitLogFormat}`, `${from ? `${from}..` : ''}${to}`]) | ||
.then(result => result.stdout + "\n"); | ||
return gitLog.split(LOG_COMMIT_DELIMITER + '\n').slice(0, -1) | ||
.map(commit => commit.split(LOG_FIELD_SEPARATOR)) | ||
const gitLog = await execAsync(`git log --reverse --format=${gitLogFormat} ${from ? `${from}..` : ''}${to}`, {encoding: 'UTF-8'}) | ||
.then(result => result.split(LOG_COMMIT_DELIMITER + '\n').slice(0, -1)); | ||
return gitLog.map(commit => commit.split(LOG_FIELD_SEPARATOR)) | ||
.map(commit => ({ | ||
@@ -49,4 +48,4 @@ hash: commit[0], | ||
const hashArray = await execa('git', ['rev-parse', `${rev1}^{}`, `${rev2}^{}`]) | ||
.then(result => result.stdout.split('\n')); | ||
const hashArray = await execAsync(`git rev-parse '${rev1}^{}' '${rev2}^{}'`, {encoding: 'UTF-8'}) | ||
.then(result => result.split('\n')); | ||
@@ -59,2 +58,2 @@ return hashArray[0] === hashArray[1]; | ||
commitLog: getCommitLog | ||
}; | ||
}; |
const Git = require("./git"); | ||
module.exports = function(convention, commitAnchor = 'HEAD') { | ||
let lastTag | ||
@@ -11,3 +11,3 @@ let commitLog | ||
lastTag = await Git.lastTag(convention.releaseTagGlobPattern, commitAnchor) | ||
} | ||
} | ||
return lastTag | ||
@@ -50,3 +50,3 @@ } | ||
}; | ||
(await getCommitLog()).forEach(commit => { | ||
@@ -153,2 +153,2 @@ if (commit.breakingChanges && commit.breakingChanges.length) { | ||
this.version = getVersion; | ||
}; | ||
}; |
{ | ||
"name": "git-conventional-commits", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "git conventional commits util", | ||
@@ -15,8 +15,7 @@ "licence": "MIT", | ||
"dependencies": { | ||
"execa": "^5.0.0", | ||
"yargs": "^16.1.1" | ||
"yargs": "^17.3.1" | ||
}, | ||
"devDependencies": { | ||
"jest": "^26.1.0", | ||
"tmp-promise": "^3.0.2" | ||
"jest": "^27.5.1", | ||
"tmp-promise": "^3.0.3" | ||
}, | ||
@@ -23,0 +22,0 @@ "bin": { |
@@ -1,3 +0,4 @@ | ||
# Git Conventional Commits | ||
# Git Conventional Commits [![Sparkline](https://stars.medv.io/qoomon/git-conventional-commits.svg)](https://stars.medv.io/qoomon/git-conventional-commits) | ||
[![npm](https://img.shields.io/npm/v/git-conventional-commits)](https://www.npmjs.com/package/git-conventional-commits) | ||
@@ -7,2 +8,5 @@ | ||
### Changelog | ||
see [CHANGELOG.md](CHANGELOG.md) | ||
### Install | ||
@@ -51,5 +55,5 @@ `npm install --global git-conventional-commits` | ||
"perf", | ||
"merge", | ||
"?" | ||
"merge" | ||
], | ||
"includeInvalidCommits": true, | ||
"commitScopes": [], | ||
@@ -92,5 +96,4 @@ "commitIgnoreRegexPattern": "^WIP ", | ||
* `merge` commits | ||
* `?` commits with unexpected message format | ||
* if not set or empty commit type filter is disabled | ||
* e.g. `["feat", "fix", "merge" , "?"]` | ||
* e.g. `["feat", "fix", "merge"]` | ||
* `commitScopes` filter commits by scopes | ||
@@ -100,2 +103,4 @@ * a subset of `convention.commitScopes` | ||
* e.g. `["ui"]` | ||
* `includeInvalidCommits` include commits without valid type: default: `true` | ||
* if set to false all commits with undefined `commitTypes` will be removed from changelog | ||
* `commitIgnoreRegexPattern` filter commits by commit subject regex | ||
@@ -102,0 +107,0 @@ * default `^WIP ` |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
30676
1
13
633
158
1
+ Addedcliui@8.0.1(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
- Removedexeca@^5.0.0
- Removedcliui@7.0.4(transitive)
- Removedcross-spawn@7.0.6(transitive)
- Removedexeca@5.1.1(transitive)
- Removedget-stream@6.0.1(transitive)
- Removedhuman-signals@2.1.0(transitive)
- Removedis-stream@2.0.1(transitive)
- Removedisexe@2.0.0(transitive)
- Removedmerge-stream@2.0.0(transitive)
- Removedmimic-fn@2.1.0(transitive)
- Removednpm-run-path@4.0.1(transitive)
- Removedonetime@5.1.2(transitive)
- Removedpath-key@3.1.1(transitive)
- Removedshebang-command@2.0.0(transitive)
- Removedshebang-regex@3.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedstrip-final-newline@2.0.0(transitive)
- Removedwhich@2.0.2(transitive)
- Removedyargs@16.2.0(transitive)
- Removedyargs-parser@20.2.9(transitive)
Updatedyargs@^17.3.1