Skip to content

Commit 9d2e904

Browse files
committed
Tooling: Add setup-pre-commit make target
pre-commit does not install commit-msg type hooks by default. The make target will install all our hook types automatically. See https://pre-commit.com/#pre-commit-configyaml---top-level Update CONTRIBUTING with new make target info.
1 parent fc24106 commit 9d2e904

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Follow our [Getting Started Guide](https://github.com/nginxinc/nginx-hugo-theme/
2424
We use [pre-commit](https://pre-commit.com/#install) for local pre-commit hooks.
2525
To get setup:
2626
- Install [pre-commit ](https://pre-commit.com/#install)
27-
- Install the hooks `pre-commit install`
27+
- Run the make target `make setup-pre-commit`
2828

2929
### Report a Bug
3030

Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ list help::
1313
@echo " biome-all: Runs both the lint and formatting commands."
1414
@echo " (Set BIOME_ARGS to add additional arguments to biome command (ex: make biome-all BIOME_ARGS=write))"
1515

16-
.PHONY: biome-format biome-lint biome-all
16+
.PHONY: biome-format biome-lint biome-all setup-pre-commit
1717
BIOME_ARGS ?=
1818
FLAG :=
1919
ifeq ($(BIOME_ARGS), write)
@@ -25,4 +25,14 @@ biome-format:
2525
biome-lint:
2626
$(BIOME_BASE_CMD) lint $(BIOME_CONFIG_PATH) $(FLAG)
2727
biome-all:
28-
$(BIOME_BASE_CMD) check $(BIOME_CONFIG_PATH) $(FLAG)
28+
$(BIOME_BASE_CMD) check $(BIOME_CONFIG_PATH) $(FLAG)
29+
30+
setup-pre-commit:
31+
@if ! command -v pre-commit &> /dev/null; then \
32+
echo "WARNING: 'pre-commit' is not installed. Please install it using: pip install pre-commit or brew install pre-commit"; \
33+
else \
34+
echo "pre-commit is installed! Proceeding with hook installation."; \
35+
pre-commit install; \
36+
pre-commit install --hook-type commit-msg; \
37+
echo "pre-commit hooks have been successfully installed."; \
38+
fi

0 commit comments

Comments
 (0)