-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use lib/; my-cmd hooks; use printf; more vendor filtering (#13)
* Refactored to use include files, removing duplicate code * Adds my-cmd hooks to invoke custom tools * Replaces all usages of echo with printf * Adds more vendor filtering * Updates project description * Reverts copy/pasta in go-test hook docs added in gosec commit * Adds shellcheck hook to lint project files * Adds shfmt hook to normalize formatting in project files * Updates copyright year in LICENSE file
- Loading branch information
Showing
49 changed files
with
645 additions
and
1,231 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
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 |
---|---|---|
@@ -1,70 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
# shellcheck disable=SC2034 # vars used by sourced script | ||
error_on_output=0 | ||
cmd=(go build -o /dev/null) | ||
|
||
export GO111MODULE=on | ||
|
||
# Walks up the file path looking for go.mod | ||
# | ||
function find_module_roots() { | ||
for arg in "$@" ; do | ||
local path="${arg}" | ||
if [ "${path}" == "" ]; then | ||
path="." | ||
elif [ -f "${path}" ]; then | ||
path=$(dirname "${path}") | ||
fi | ||
while [ "${path}" != "." ] && [ ! -f "${path}/go.mod" ]; do | ||
path=$(dirname "${path}") | ||
done | ||
if [ -f "${path}/go.mod" ]; then | ||
echo "${path}" | ||
fi | ||
done | ||
} | ||
|
||
OPTIONS=() | ||
# If arg doesn't pass [ -f ] check, then it is assumed to be an option | ||
# | ||
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do | ||
OPTIONS+=("$1") | ||
shift | ||
done | ||
|
||
FILES=() | ||
# Assume start of file list (may still be options) | ||
# | ||
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do | ||
FILES+=("$1") | ||
shift | ||
done | ||
|
||
# If '--' next, then files = options | ||
# | ||
if [ $# -gt 0 ]; then | ||
if [ "$1" == "-" ] || [ "$1" == "--" ]; then | ||
shift | ||
# Append to previous options | ||
# | ||
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}") | ||
FILES=() | ||
fi | ||
fi | ||
|
||
# Any remaining arguments are assumed to be files | ||
# | ||
while [ $# -gt 0 ]; do | ||
FILES+=("$1") | ||
shift | ||
done | ||
|
||
errCode=0 | ||
for sub in $(find_module_roots "${FILES[@]}" | sort -u) ; do | ||
pushd "${sub}" >/dev/null | ||
"${cmd[@]}" "${OPTIONS[@]}" ./... | ||
if [ $? -ne 0 ]; then | ||
errCode=1 | ||
fi | ||
popd >/dev/null | ||
done | ||
exit $errCode | ||
# shellcheck source=lib/cmd-mod.bash | ||
. "$(dirname "${0}")/lib/cmd-mod.bash" |
Oops, something went wrong.