Skip to content
forked from NvChad/NvChad

Commit 5aa9009

Browse files
committed
build(hooks): add conventional commits git hook and make target
1 parent 2641958 commit 5aa9009

File tree

3 files changed

+51
-2
lines changed

3 files changed

+51
-2
lines changed

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,21 @@ install-windows:
9797
echo "- Hack Nerd Font"; \
9898
fi
9999

100+
# Install git hooks
101+
.PHONY: hooks
102+
hooks:
103+
@echo "Installing git hooks..."
104+
@cp scripts/commit-msg .git/hooks/commit-msg
105+
@chmod +x .git/hooks/commit-msg
106+
@echo "Git hooks installed successfully."
107+
100108
# Help target
101109
.PHONY: help
102110
help:
103111
@echo "Available targets:"
104-
@echo " install - Install dependencies for the detected OS"
112+
@echo " install - Install dependencies for the detected OS"
105113
@echo " install-macos - Install dependencies for macOS (requires Homebrew)"
106114
@echo " install-linux - Install dependencies for Linux (apt/yum/pacman)"
107115
@echo " install-windows - Install dependencies for Windows (Chocolatey/Scoop)"
108-
@echo " help - Show this help message"
116+
@echo " hooks - Install git hooks for conventional commits"
117+
@echo " help - Show this help message"

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,30 @@ NVIM_APPNAME=le4ker/NvMegaChad nvim
118118
| Vimscript | [vim-language-server](https://github.com/iamcco/vim-language-server) ||||
119119
| SQL || [sql-formatter](https://github.com/sql-formatter-org/sql-formatter) |||
120120

121+
## 🛠️ Development
122+
123+
### Git Hooks Setup
124+
125+
This repository uses [Conventional Commits](https://www.conventionalcommits.org/). To enforce this on your local clone, run:
126+
127+
```sh
128+
make hooks
129+
```
130+
131+
This installs a commit-msg hook that validates your commit messages follow the format:
132+
133+
```
134+
<type>(<scope>): <description>
135+
```
136+
137+
**Allowed types:** `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
138+
139+
**Examples:**
140+
141+
- `feat(mappings): add new keybinding for terminal`
142+
- `fix(lsp): resolve null reference error`
143+
- `docs: update README`
144+
121145
## 📄 License
122146

123147
See [LICENSE](LICENSE) for details.

scripts/commit-msg

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
commit_regex='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?: .{1,}'
3+
4+
if ! grep -qE "$commit_regex" "$1"; then
5+
echo "ERROR: Commit message does not follow Conventional Commits format."
6+
echo ""
7+
echo "Format: <type>(<scope>): <description>"
8+
echo ""
9+
echo "Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
10+
echo ""
11+
echo "Examples:"
12+
echo " feat(mappings): add new keybinding for terminal"
13+
echo " fix(lsp): resolve null reference error"
14+
echo " docs: update README"
15+
exit 1
16+
fi

0 commit comments

Comments
 (0)