Skip to content

Commit 86f32f7

Browse files
committed
feat: add git commit hooks to automatically run find . \( -name '*.c' -o -name '*.h' \) -print0 | xargs -0 clang-format -i and Linting with compiler warnings...
Lint passed!
1 parent 05f1382 commit 86f32f7

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ Thanks for your interest in contributing! This guide will help you get started.
77
1. Fork and clone the repository
88
2. Create a new branch: `git checkout -b my-fix`
99
3. Make your changes
10-
4. Format your code: `make format`
11-
5. Test your changes: `make`
12-
6. Commit and push
13-
7. Open a pull request
10+
4. Build: `make` (this also installs git hooks automatically)
11+
5. Commit and push (the git commit hook will check formatting and lint)
12+
6. Open a pull request
1413

1514
## Requirements
1615

@@ -50,11 +49,14 @@ sudo dnf install clang-tools-extra
5049
| `make format-check` | Check formatting (used by CI) |
5150
| `make lint` | Run linter checks |
5251
| `make check` | Run all checks (format + lint) |
52+
| `make install-hooks` | Install git pre-commit hook (runs automatically) |
5353
| `make clean` | Remove compiled files |
5454

5555
## Before Submitting
5656

57-
Please run these commands before submitting a pull request:
57+
Git hooks are installed automatically when you run `make`, so formatting and linting checks will run before each commit.
58+
59+
You can also run checks manually:
5860

5961
```shell
6062
make format # Format your code

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ EXECS = $(SOURCES:%.c=%)
66
LDLIBS = -lm
77
CFLAGS = -Wall -Wextra -Wpedantic
88

9-
all: $(EXECS)
9+
all: install-hooks $(EXECS)
1010

1111
lint:
1212
@echo "Linting with compiler warnings..."
@@ -23,11 +23,18 @@ format-check:
2323

2424
check: format-check lint
2525

26+
install-hooks:
27+
@if [ -d .git ] && [ ! -f .git/hooks/pre-commit ]; then \
28+
cp scripts/pre-commit .git/hooks/pre-commit; \
29+
chmod +x .git/hooks/pre-commit; \
30+
echo "Pre-commit hook installed."; \
31+
fi
32+
2633
clean:
2734
@for f in $(EXECS) $(DEBUG_FILES); do \
2835
if [ -e "$$f" ] || [ -d "$$f" ]; then \
2936
rm -rf "$$f" && echo "Removed: $$f"; \
3037
fi; \
3138
done
3239

33-
.PHONY: all lint format format-check check clean
40+
.PHONY: all lint format format-check check install-hooks clean

0 commit comments

Comments
 (0)