From 435a2ceb5dfac6ef48eb1e91709ed08750904c47 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Fri, 25 Sep 2015 07:29:15 +0000 Subject: [PATCH] Add support for weave in lint script. --- lint | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lint b/lint index aac233b84..080713486 100755 --- a/lint +++ b/lint @@ -11,7 +11,25 @@ # To use this script automatically, run: # ln -s ../../bin/lint .git/hooks/pre-commit -set -eu +set -e + +IGNORE_LINT_COMMENT= +IGNORE_TEST_PACKAGES= +while true; do + case "$1" in + -nocomment) + IGNORE_LINT_COMMENT=1 + shift 1 + ;; + -notestpackage) + IGNORE_TEST_PACKAGES=1 + shift 1 + ;; + *) + break + esac +done + function spell_check { filename="$1" @@ -64,7 +82,11 @@ function lint_go { # don't have it installed. if type golint >/dev/null 2>&1; then # golint doesn't set an exit code it seems - lintoutput=$(golint "${filename}") + if [ "$IGNORE_LINT_COMMENT" = "1" ]; then + lintoutput=$(golint "${filename}" | grep -vE 'comment|dot imports') + else + lintoutput=$(golint "${filename}") + fi if [ "$lintoutput" != "" ]; then lint_result=1 echo "$lintoutput" @@ -105,8 +127,10 @@ function lint { ;; esac - if [[ $filename == *"_test.go" ]]; then - test_mismatch "${filename}" || lint_result=1 + if [ -z "$IGNORE_TEST_PACKAGES" ]; then + if [[ "$filename" == *"_test.go" ]]; then + test_mismatch "${filename}" || lint_result=1 + fi fi spell_check "${filename}" || lint_result=1