-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
precommit: lint importing of testutil
- Loading branch information
1 parent
19b3263
commit bbe4c00
Showing
5 changed files
with
36 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
FILES=$@ | ||
|
||
# check runs a regexp check on the given files | ||
function check() { | ||
grep -HnE "$2" $FILES && printf "\n❌ Regexp check failed: %s\n\n" "$1" | ||
} | ||
|
||
# exclude_names excludes file names matching the given regex from the list of files | ||
function exclude_names() { | ||
FILES=$(echo $FILES | tr ' ' '\n' | grep -vE "$1" | tr '\n' ' ') | ||
} | ||
|
||
# exclude_names excludes files with content matching the given regex from the list of files | ||
function exclude_content() { | ||
FILES=$(echo $FILES | tr ' ' '\n' | xargs grep -LZE "$1" | tr '\n' ' ') | ||
} | ||
|
||
# Exclude all file names with 'test' in the path. | ||
exclude_names 'test' | ||
exclude_content '// Allow testutil' | ||
|
||
# These checks apply to all non-test files | ||
check 'Testutil package may only be imported by tests' 'github.com/obolnetwork/charon/testutil' && exit 1 | ||
|
||
true |
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