Added pre-commit hooks

This commit is contained in:
Jakob Meier 2023-12-22 20:27:26 +01:00
parent 50b6d038c3
commit 2fa9486db3
No known key found for this signature in database
GPG key ID: 66BDC7E6A01A6152
2 changed files with 20 additions and 0 deletions

View file

@ -16,3 +16,19 @@ This app uses /l10n/ according to the official flutter
We use [weblate](https://translate.codeberg.org/engage/outbag/) to manage translations.
[![Translation status](https://translate.codeberg.org/widget/outbag/outbag-app/multi-auto.svg)](https://translate.codeberg.org/engage/outbag/)
## Contributing
To keep the code formatted properly,
we use git hooks to format files before committing.
You can easily add git-hooks using the following command:
``` sh
git config core.hooksPath ./hooks
```
Afterwards the `pre-commit` hook will automatically be run,
when you commit your changes:
``` sh
git add # some files
git commit
```

4
hooks/pre-commit Executable file
View file

@ -0,0 +1,4 @@
git_dir=$(git rev-parse --git-dir)
project_dir=$(dirname $git_dir)
dart format $project_dir