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

chore: add githooks #2

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

#ignore merges
isMerge=$(git rev-parse -q --verify MERGE_HEAD)
if [ -n "$isMerge" ]; then
exit
fi

# fix with linter
dart fix --apply

# Regexp for grep to only choose some file extensions for formatting
exts="\.\(dart\)$"
echo "Pre-commit: formatting changed files"
# Format staged files
for file in $(git diff --cached --name-only --diff-filter=ACMR | grep $exts); do
echo "Formatting $file"
dart format --line-length=120 $file
git add $file
done
17 changes: 17 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

printf "\e[33;1m%s\e[0m\n" 'Running the Flutter analyzer'
flutter analyze
if [ $? -ne 0 ]; then
printf "\e[31;1m%s\e[0m\n" 'Flutter analyzer error'
exit 1
fi
printf "\e[33;1m%s\e[0m\n" 'Finished running the Flutter analyzer'

printf "\e[33;1m%s\e[0m\n" 'Running unit tests'
flutter test
if [ $? -ne 0 ]; then
printf "\e[31;1m%s\e[0m\n" 'Unit tests error'
exit 1
fi
printf "\e[33;1m%s\e[0m\n" 'Finished running unit tests'
28 changes: 28 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Description
<!--
Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context.
List any dependencies that are required for this change.
-->

## How Has This Been Tested?
<!--
Please describe the tests that you ran to verify your changes. For larger features, provide
reproducible instructions.
-->

## Screenshots
<!--
A simple screenshot of the before and after, or of the current state vs. your local development
view, helps the reviewer tremendously.
-->

## Type of Change

<!--- Put an `x` in all the boxes that apply: -->

- [ ] ✨ New feature (non-breaking change which adds functionality)
- [ ] 🛠️ Bug fix (non-breaking change which fixes an issue)
- [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change)
- [ ] 🧹 Code refactor
- [ ] 🗑️ Chore
Loading