forked from evmos/safe-web-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add husky pre-push hook (#3319)
* feat: add husky pre-push hook Prior to pushing to remote, check and fix any linting issues. If an issue was found and fixed, we’ll prevent the user from pushing - he would have to commit the changed files. If you want to run the test suite on pushing you can set the RUN_TESTS_ON_PUSH variable to true. Co-authored-by: katspaugh <[email protected]>
- Loading branch information
Showing
4 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# Store the initial git status | ||
initial_status=$(git status --porcelain) | ||
|
||
# Run the lint command | ||
yarn run lint --fix | ||
|
||
# Store the status after running lint | ||
post_lint_status=$(git status --porcelain) | ||
|
||
# Compare the initial and post-lint statuses | ||
if [ "$initial_status" != "$post_lint_status" ]; then | ||
echo "====================================" | ||
echo "Linters gonna lint!" | ||
echo "Linting made changes. Please commit these changes before pushing or push with --no-verify flag to omit this check." | ||
echo "====================================" | ||
exit 1 | ||
fi | ||
|
||
# Check if the user wants to run tests on push | ||
if [ "$RUN_TESTS_ON_PUSH" == "true" ]; then | ||
echo "Running tests..." | ||
if ! yarn test; then | ||
echo "====================================" | ||
echo "Tests failed. Guess they need more 'exercise'!" | ||
echo "Please fix the issues before pushing or push with --no-verify flag to omit this check." | ||
echo "====================================" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# All goooood in safe's land! | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10613,6 +10613,11 @@ humanize-ms@^1.2.1: | |
dependencies: | ||
ms "^2.0.0" | ||
|
||
husky@^9.0.11: | ||
version "9.0.11" | ||
resolved "https://registry.yarnpkg.com/husky/-/husky-9.0.11.tgz#fc91df4c756050de41b3e478b2158b87c1e79af9" | ||
integrity sha512-AB6lFlbwwyIqMdHYhwPe+kjOC3Oc5P3nThEoW/AaO2BX3vJDjWPFxYLxokUZOo6RNX20He3AaT8sESs9NJcmEw== | ||
|
||
[email protected], iconv-lite@~0.4.13: | ||
version "0.4.24" | ||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" | ||
|