To reduce the feedback loop for a failed build when formatting is not acceptable we agreed to run the formatter as part of the commit. Using https://github.com/hallettj/git-format-staged allows us to only format staged files, leaving other files untouched.
Tasks
[x] Add pre commit hook
[x] configure git hook on ./build-ios.sh
Infos for Reviewer
I tested this without SwiftFormat installed: The commit will fail with an error message explaining to install SwiftFormat. You still have the option to ignore the hook and commit directly.
Git, by default, does not distribute hooks when a repository is cloned. This design choice is intentional to prevent arbitrary code execution on users’ machines for security reasons. Therefore we need the workaround, where we configure the git hooks path as part for build-ios.sh
Description
To reduce the feedback loop for a failed build when formatting is not acceptable we agreed to run the formatter as part of the commit. Using https://github.com/hallettj/git-format-staged allows us to only format staged files, leaving other files untouched.
Tasks
./build-ios.sh
Infos for Reviewer
I tested this without SwiftFormat installed: The commit will fail with an error message explaining to install SwiftFormat. You still have the option to ignore the hook and commit directly.
Git, by default, does not distribute hooks when a repository is cloned. This design choice is intentional to prevent arbitrary code execution on users’ machines for security reasons. Therefore we need the workaround, where we configure the git hooks path as part for
build-ios.sh