Skip to content

Commit 6e29fc9

Browse files
authored
Merge pull request #1836 from DGtal-team/precommitdoc
Add pre-commit setup instructions to contributing documentation
2 parents 315e351 + db446f0 commit 6e29fc9

File tree

4 files changed

+143
-50
lines changed

4 files changed

+143
-50
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ b2/
4949
examples/samples/bunny-512.vol
5050
src/DGtal/dec/doc/images/poly/paf.png
5151
src/cppclean.log
52-
.vscode/
52+
.vscode/
53+
.cache/

CONTRIBUTING.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,66 @@ tests.
4848
More information are described in the
4949
[DGtal documentation](http://dgtal.org/doc/stable/moduleFAQGit.html).
5050

51+
## Setting up Pre-commit Hooks
52+
53+
DGtal uses [pre-commit](https://pre-commit.com/) to ensure code quality and consistency. Before making contributions, we highly recommend setting up pre-commit hooks:
54+
55+
### Installation
56+
57+
1. **Install pre-commit** (if not already installed):
58+
```bash
59+
pip install pre-commit
60+
```
61+
62+
2. **Install the hooks** in your local repository:
63+
```bash
64+
cd /path/to/DGtal
65+
pre-commit install
66+
```
67+
68+
### What the hooks do
69+
70+
The current pre-commit configuration (`/.pre-commit-config.yaml`) includes:
71+
- Removes trailing whitespace
72+
- Ensures files end with a newline
73+
- Validates YAML syntax
74+
- Prevents large files from being committed
75+
- Checks for broken symlinks
76+
- Detects case conflicts in filenames
77+
78+
### Running hooks manually
79+
80+
To run all hooks on all files:
81+
```bash
82+
pre-commit run --all-files
83+
```
84+
85+
To run hooks on specific files:
86+
```bash
87+
pre-commit run --files path/to/your/files
88+
```
89+
90+
### Updating hooks
91+
92+
To update to the latest versions of the hooks:
93+
```bash
94+
pre-commit autoupdate
95+
pre-commit run --all-files
96+
```
97+
98+
### Skipping hooks (not recommended)
99+
100+
If you absolutely need to skip hooks (not recommended for regular development):
101+
```bash
102+
git commit --no-verify -m "Commit message"
103+
```
104+
105+
### Troubleshooting
106+
107+
- If hooks fail, fix the reported issues and try committing again
108+
- For persistent issues, you can temporarily disable specific hooks in `/.pre-commit-config.yaml`
109+
- Ensure you're using a compatible Python version (3.6+)
110+
51111
## Code Structure
52112

53113
### Folders

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- *Project*
66
- pre-commit hooks have been activated for sanity checks on files before running the git commit (David Coeurjolly, [#1835](https://github.com/DGtal-team/DGtal/pull/1835))
7+
- Add pre-commit setup instructions to contributing documentation (David Coeurjolly, [#1836](https://github.com/DGtal-team/DGtal/pull/1836))
78

89
## Changes
910

0 commit comments

Comments
 (0)