-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* pre-commit hook and reqs * Updated pre-commit file * Added hook setup file * Updated linting step to only use yapf and only lint staged files * Removed redundant yapf from environment * Updated developer readme on github * Edited dev readme * Updated web documentation * Updated installation.rst * Deleted extra whitespace * Added hook_setup confirmation and updated documentation * Standardized shell files * Updated documentation * updated pre-commit hook Co-authored-by: Priti Ashvin Shah <[email protected]>
- Loading branch information
1 parent
3c78735
commit 2f85eeb
Showing
4 changed files
with
62 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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
ln -s -f ../../hooks/pre-commit .git/hooks/pre-commit | ||
ret=$? | ||
if [[ $ret != 0 ]]; then | ||
echo "Linking hooks failed with rc $ret" | ||
else | ||
echo "Linking hooks succeeded!" | ||
fi |
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,33 @@ | ||
#!/bin/bash | ||
|
||
echo "Checking dependencies" | ||
which yapf &> /dev/null | ||
ret=$? | ||
if [[ $ret != 0 ]]; then | ||
echo "Please install yapf to use pre-commit hook" | ||
exit 1 | ||
else | ||
echo "All dependencies present" | ||
fi | ||
|
||
echo "Begin linting step using yapf formatting" | ||
linterrorfound=0 | ||
for stagedfile in $(git diff --name-only --cached | grep .*.py) | ||
do | ||
yapf --diff --style .style.yapf $stagedfile | ||
ret=$? | ||
if [[ $ret != 0 ]]; then | ||
linterrorfound=1 | ||
echo ">>> Errors in file $stagedfile" | ||
fi | ||
done | ||
|
||
if [[ $linterrorfound == 1 ]]; then | ||
echo "Please fix linting errors before committing" | ||
exit 1 | ||
else | ||
echo "Linting successful" | ||
fi | ||
|
||
echo "Python linting validation completed!" | ||
exit 0 |