Skip to content

Commit d631dc1

Browse files
authored
Merge pull request #238 from MightyCreak/chore/add-git-hooks
chore: add pre-commit git hooks to run linters
2 parents 2876332 + e4eca4d commit d631dc1

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.githooks/pre-commit

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
txtred='\e[0;31m'
6+
txtbld='\e[1m'
7+
txtrst='\e[0m'
8+
9+
if ! flake8 src/ po/
10+
then
11+
echo -e "${txtred}${txtbld}Linter error(s) from flake8${txtrst}"
12+
exit 1
13+
fi
14+
15+
if ! mypy src/ po/
16+
then
17+
echo -e "${txtred}${txtbld}Linter error(s) from mypy${txtrst}"
18+
exit 1
19+
fi

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Translation: update Portuguese translation (@hugok79)
1515
- Translation: add 'nl' in LINGUAS (@hugok79)
1616
- Update pypi packages (@MightyCreak)
17+
- Add pre-commit git hooks to run linters (@MightyCreak)
1718

1819
## 0.9.0 - 2024-01-13
1920

docs/developers/developers-setup.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ Diffuse depends on these projects:
1010
* Meson
1111
* Flatpak and Flatpak builder (Linux only)
1212

13+
### Install git hooks (optional)
14+
15+
There is a pre-commit git hook that runs some linters on the source code before committing.
16+
17+
To install the git hooks (for the repository only), run this command:
18+
19+
```sh
20+
git config --local core.hooksPath ./.githooks
21+
```
22+
1323
## Install the dependencies
1424

1525
### Install the system dependencies

0 commit comments

Comments
 (0)