Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit hook #867

Merged
merged 9 commits into from
Jul 27, 2023
14 changes: 14 additions & 0 deletions pre-commit-hook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

tee .git/hooks/pre-commit << EOF
#!/bin/sh

FILES="\$(git diff --name-only --cached | grep .*\.dart | grep -v .*\.g\.dart)"



echo "\$FILES" | xargs dart format
echo "\$FILES" | xargs git add
EOF

chmod +x .git/hooks/pre-commit
9 changes: 9 additions & 0 deletions uni/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ The token is read from the file assets/env/env.json, which you may need to creat
}
```

### Automated formatting

In order to contribute, you must format you files using `dart format` manually or formatting on save using your IDE automatically, or you can install the git pre-commit hook doing the following command at the root of the directory that automatically formats staged files:
LuisDuarte1 marked this conversation as resolved.
Show resolved Hide resolved

``` bash
chmod +x pre-commit-hook.sh && ./pre-commit-hook.sh
```


## Project structure

### Overview
Expand Down