From 2fa9486db343469d8b266d5be3e5817ed40e0088 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 22 Dec 2023 20:27:26 +0100 Subject: [PATCH] Added pre-commit hooks --- README.md | 16 ++++++++++++++++ hooks/pre-commit | 4 ++++ 2 files changed, 20 insertions(+) create mode 100755 hooks/pre-commit diff --git a/README.md b/README.md index fdc7ece..03b3c21 100644 --- a/README.md +++ b/README.md @@ -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 +``` diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100755 index 0000000..95066ae --- /dev/null +++ b/hooks/pre-commit @@ -0,0 +1,4 @@ +git_dir=$(git rev-parse --git-dir) +project_dir=$(dirname $git_dir) + +dart format $project_dir