git-conventional-commits
Advanced tools
Comparing version 2.6.7 to 2.7.0
@@ -65,3 +65,3 @@ const Config = require("./config"); | ||
commitScopes: config.changelog.commitScopes, | ||
commitIgnoreRegex: new RegExp(config.changelog.commitIgnoreRegexPattern, "m") | ||
commitIgnoreRegex: config.changelog.commitIgnoreRegex(), | ||
}); | ||
@@ -68,0 +68,0 @@ |
@@ -29,5 +29,8 @@ const fs = require("fs"); | ||
conventionConfig.releaseTagGlobPattern; | ||
conventionConfig.msgRegex = RegExp(conventionOverride.commitMessageRegexPattern) || conventionConfig.msgRegex; | ||
conventionConfig.commitTypes = conventionOverride.commitTypes || conventionConfig.commitTypes; | ||
conventionConfig.featureCommitTypes = conventionOverride.featureCommitTypes || conventionConfig.featureCommitTypes; | ||
conventionConfig.commitScopes = conventionOverride.commitScopes || conventionConfig.commitScopes; | ||
// Legacy support convention.issueRegexPattern | ||
@@ -37,2 +40,7 @@ config.changelog.issueRegexPattern = conventionOverride.issueRegexPattern || config.changelog.issueRegexPattern; | ||
// check for mandatory capturing groups | ||
if (!hasAllCapturingGroups(config.convention.msgRegex, ['type', 'scope', 'breaking', 'description'])) { | ||
throw new Error(`msgRegex: ${config.convention.msgRegex.source} does not have all mandatory capture groups ('type', 'scope', 'breaking', 'description')`); | ||
} | ||
if (configOverride.changelog) { | ||
@@ -111,3 +119,3 @@ const changelogConfig = config.changelog; | ||
config.changelog.commitIgnoreRegex = () => RegExp(config.changelog.commitIgnoreRegexPattern || '(?!)'); | ||
config.changelog.commitIgnoreRegex = () => RegExp(config.changelog.commitIgnoreRegexPattern || '(?!)',"m"); | ||
@@ -122,2 +130,7 @@ config.changelog.issueRegex = () => RegExp( | ||
function hasAllCapturingGroups(exp, groups) { | ||
return groups.every(group => exp.source.includes(`(?<${group}>`)); | ||
} | ||
module.exports = { | ||
@@ -128,2 +141,3 @@ defaultPath, | ||
defaultConfig, | ||
hasAllCapturingGroups | ||
} |
@@ -72,3 +72,3 @@ const Git = require("./git"); | ||
// 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) { | ||
@@ -91,5 +91,9 @@ conventionalCommit.breakingChanges = [conventionalSubject.description] | ||
conventionalSubject.type = msgMatch.groups.type; | ||
if (!conventionalSubject.type) | ||
throw new Error(`Invalid msgRegex: ${convention.msgRegex}. Capturing group 'type' is empty.`); | ||
conventionalSubject.scope = msgMatch.groups.scope === '' ? undefined : msgMatch.groups.scope; | ||
conventionalSubject.breaking = msgMatch.groups.breaking === '!'; | ||
conventionalSubject.description = msgMatch.groups.description; | ||
if (!conventionalSubject.description) | ||
throw new Error(`Invalid msgRegex: ${convention.msgRegex}. Capturing group 'description' is empty.`); | ||
} else { | ||
@@ -96,0 +100,0 @@ const msgMergeMatch = getFirstMatch(commit.subject, convention.msgMergeRegexList); |
{ | ||
"name": "git-conventional-commits", | ||
"version": "2.6.7", | ||
"version": "2.7.0", | ||
"description": "git conventional commits util", | ||
@@ -5,0 +5,0 @@ "licence": "GPLv3", |
@@ -1,7 +0,7 @@ | ||
# Git Conventional Commits [![Sparkline](https://stars.medv.io/qoomon/git-conventional-commits.svg)](https://stars.medv.io/qoomon/git-conventional-commits) | ||
# Git Conventional Commits [![starline](https://starlines.qoo.monster/assets/qoomon/git-conventional-commits)](https://github.com/qoomon/starlines) | ||
[![npm](https://img.shields.io/npm/v/git-conventional-commits)](https://www.npmjs.com/package/git-conventional-commits) | ||
**ℹ Have a look at [Git Commit Conventions](https://gist.github.com/qoomon/5dfcdf8eec66a051ecd85625518cfd13)** | ||
> [!TIP] | ||
> Also have a look at **[Git Conventional Commits Cheat Sheet](https://gist.github.com/qoomon/5dfcdf8eec66a051ecd85625518cfd13)** | ||
@@ -11,13 +11,8 @@ ### Changelog | ||
### Install | ||
`npm install --global git-conventional-commits` | ||
### Usage | ||
* Create [config file](#config-file) `git-conventional-commits init` | ||
* Adjust config `git-conventional-commits.yaml` to your needs | ||
`npx git-conventional-commits <command>` | ||
#### Commands | ||
ℹ add help parameter `-h` to commands to list all possible options | ||
``` | ||
init [options] creates a config file template `git-conventional-commits.yaml` | ||
init [options] create a config file template `git-conventional-commits.yaml` | ||
version [options] determine version from conventional commits | ||
@@ -27,2 +22,6 @@ changelog [options] generate change log from conventional commits | ||
``` | ||
#### First Usage | ||
* Run `npx git-conventional-commits init` | ||
* Adjust [config file](#config-file) `git-conventional-commits.yaml` to your needs | ||
@@ -122,3 +121,3 @@ #### Config File | ||
- repo: https://github.com/qoomon/git-conventional-commits | ||
rev: <revision e.g. v2.6.5> | ||
rev: <RELEASE_TAG> | ||
hooks: | ||
@@ -144,14 +143,15 @@ - id: conventional-commits | ||
git-conventional-commits commit-msg-hook "$1" | ||
npx git-conventional-commits commit-msg-hook "$1" | ||
``` | ||
* Add and commit `.git-hooks/commit-msg` to repository | ||
* ⚠️ Whenever you clone your repository with git hooks you need to enable git hooks once again | ||
* `git config core.hooksPath .git-hooks` | ||
> [!IMPORTANT] | ||
> Whenever you clone your repository with git hooks you need to enable git hooks once again | ||
> <br>`git config core.hooksPath .git-hooks` | ||
### Release Workflow with `git-conventional-commits` | ||
* Determine version by `git-conventional-commits version` | ||
* Determine version by `npx git-conventional-commits version` | ||
* Update version in project files | ||
* Commit version bump `git commit -am'build(release): bump project version to <version>'` | ||
* Generate change log by `git-conventional-commits changelog --release <version> --file 'CHANGELOG.md'` | ||
* Generate change log by `npx git-conventional-commits changelog --release <version> --file 'CHANGELOG.md'` | ||
* Commit change log `git commit -am'docs(release): create <version> change log entry'` | ||
@@ -167,6 +167,10 @@ * Tag commit with version `git tag -a -m'build(release): <version>' '<version-prefix><version>'` | ||
* Push tag `git push origin v0.0.0` | ||
This way `git-conventional-commits` will use that the taged commit as the point in time to start looking for commits. | ||
This way `npx git-conventional-commits` will only considre commits based on the commit the release tag is pointing at. | ||
--- | ||
## Projects Using git-conventional-commits | ||
- https://github.com/Blazity/next-enterprise | ||
--- | ||
## Build/Release | ||
@@ -173,0 +177,0 @@ * `npm install` |
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
76508
755
177