Skip to content

Instantly share code, notes, and snippets.

@jrltt
Last active November 17, 2022 08:45
Show Gist options
  • Select an option

  • Save jrltt/1ff757df11490a62d012f6dcf9050f38 to your computer and use it in GitHub Desktop.

Select an option

Save jrltt/1ff757df11490a62d012f6dcf9050f38 to your computer and use it in GitHub Desktop.
Conventional commits & template
<type>(<optional scope>): <subject>
# Examples:
# type: build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test
# optional scope: provide additional contextual information, like: api, auth, private flow
# subject: short summary of the code changes, ex: make optional to enable public requests
#
# Final result: feat(auth): make optional to enable public requests
#!/bin/sh
git-conventional-commits commit-msg-hook "$1"
{
"convention": {
"commitTypes": [
"feat",
"fix",
"perf",
"refactor",
"style",
"test",
"build",
"docs",
"chore",
"merge",
"revert",
"ci"
],
"commitScopes": [],
"releaseTagGlobPattern": "v[0-9]*.[0-9]*.[0-9]*"
},
"changelog": {
"commitTypes": ["feat", "fix", "perf", "merge"],
"includeInvalidCommits": true,
"commitIgnoreRegexPattern": "^WIP ",
"headlines": {
"feat": "Features",
"fix": "Bug Fixes",
"perf": "Performance Improvements",
"merge": "Merges",
"breakingChange": "BREAKING CHANGES"
}
}
}
# Install globally the conventional commits CLI
# Node v14 or higher
npm install --global git-conventional-commits
# -- Configuration on single project --
# Navigate to your project
cd server-pionono/
# Run the init setup or you can just copy
# the attached `git-conventional-commits.json` into your project and commit
git-conventional-commits init
# Configure the .git/hooks for the project
# Create the hook inside the folder .git/hooks
# Inside the file the trigger of the CLI, see commit-msg
touch .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg
# Configure the hook
git config core.hooksPath .git/hooks
# Check if the configuration was done
# You should see something like this:
# core.hookspath=.git/hooks
git config --list
# -- Global configuration --
mkdir ~/.git-hooks
touch .git-hooks/commit-msg && chmod +x .git-hooks/commit-msg
# Add content (copy the script from commit-msg) into commit-msg file
# Add configuration globaly
git config --global core.hooksPath ~/.git-hooks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment