git-conventional-commits
Advanced tools
Comparing version 1.3.0 to 1.4.1
@@ -30,3 +30,3 @@ const fs = require("fs"); | ||
changelogConfig.commitTypes = changelogOverride.commitTypes || changelogConfig.commitTypes; | ||
changelogConfig.includeInvalidCommits = changelogOverride.includeInvalidCommits !== undefined | ||
changelogConfig.includeInvalidCommits = changelogOverride.includeInvalidCommits !== undefined | ||
? changelogOverride.includeInvalidCommits === true | ||
@@ -77,3 +77,3 @@ : changelogConfig.includeInvalidCommits; | ||
// regex patterns | ||
config.convention.msgRegex = /^(?<type>\w+)(?:\((?<scope>[^()]+)\))?:\s*(?<subject>.+)/i; | ||
config.convention.msgRegex = /^(?<type>\w+)(?:\((?<scope>[^()]+)\))?(?<breaking>!)?:\s*(?<description>.+)/i; | ||
config.convention.msgMergeRegex = /^Merge branch +["'](?<branch>.+)['"]/i; | ||
@@ -80,0 +80,0 @@ config.convention.msgRevertRegex = /^Revert +["'](?<subject>.+)['"]/i; |
@@ -45,17 +45,13 @@ const Git = require("./git"); | ||
// ------determine version bump --------------------------------------- | ||
const changes = { | ||
breaking: 0, | ||
feature: 0, | ||
patch: 0 | ||
}; | ||
(await getCommitLog()).forEach(commit => { | ||
if (commit.breakingChanges && commit.breakingChanges.length) { | ||
changes.breaking++; | ||
} else if (convention.featureCommitTypes.includes(commit.type)) { | ||
changes.feature++; | ||
} else { | ||
changes.patch++; | ||
} | ||
}); | ||
const changes = (await getCommitLog()).reduce((acc, commit) => { | ||
if (commit.breakingChanges && commit.breakingChanges.length) { | ||
acc.breaking++; | ||
} else if (convention.featureCommitTypes.includes(commit.type)) { | ||
acc.feature++; | ||
} else { | ||
acc.patch++; | ||
} | ||
return acc; | ||
}, {breaking: 0, feature: 0, patch: 0}); // TODO rename to breakingChanges, features and patches | ||
@@ -77,4 +73,9 @@ applyChangesToVersion(version, changes); | ||
// parse breaking changes | ||
conventionalCommit.breakingChanges = !commit.body ? [] : commit.body.split(/^BREAKING CHANGES?: */im).splice(1); | ||
conventionalCommit.breakingChanges = commit.body ? commit.body.split(/^BREAKING CHANGES?: */im).splice(1) : []; | ||
if(conventionalSubject.breaking && !conventionalCommit.breakingChanges.length) { | ||
conventionalCommit.breakingChanges = [conventionalSubject.description] | ||
} | ||
delete conventionalCommit.breaking; | ||
// parse issue ids | ||
@@ -87,3 +88,3 @@ conventionalCommit.relatedIssues = [commit.subject, commit.body].join("\n\n").match(convention.issueRegex()) || []; | ||
function parseCommitSubject(commit) { | ||
const subject = commit.subject; | ||
const subject = commit.description; | ||
let conventionalSubject; | ||
@@ -95,3 +96,4 @@ const msgMatch = subject.match(convention.msgRegex); | ||
scope: msgMatch.groups.scope === '' ? undefined : msgMatch.groups.scope, | ||
subject: msgMatch.groups.subject | ||
breaking: msgMatch.groups.breaking === '!', | ||
description: msgMatch.groups.subject | ||
} | ||
@@ -103,3 +105,3 @@ } else { | ||
type: 'merge', | ||
subject: msgMergeMatch.groups.branch | ||
description: msgMergeMatch.groups.branch | ||
}; | ||
@@ -111,3 +113,3 @@ } else { | ||
...commit, | ||
subject: msgRevertMatch.groups.subject | ||
description: msgRevertMatch.groups.description | ||
}); | ||
@@ -118,3 +120,3 @@ conventionalSubject.revert = !conventionalSubject.revert; // negate revert of revert commit | ||
conventionalSubject = { | ||
subject: subject | ||
description: subject | ||
}; | ||
@@ -121,0 +123,0 @@ } |
{ | ||
"name": "git-conventional-commits", | ||
"version": "1.3.0", | ||
"version": "1.4.1", | ||
"description": "git conventional commits util", | ||
@@ -13,3 +13,2 @@ "licence": "GPLv3", | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
@@ -19,3 +18,3 @@ "yargs": "^17.3.1" | ||
"devDependencies": { | ||
"jest": "^27.5.1", | ||
"jest": "^28.1.3", | ||
"tmp-promise": "^3.0.3" | ||
@@ -22,0 +21,0 @@ }, |
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
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
68379
2
719
2