From bb3d29f4765d3dd8eeb81dcc22ffd61c793ee0a5 Mon Sep 17 00:00:00 2001 From: Eugene Kim Date: Thu, 24 Jan 2019 23:46:03 -0800 Subject: [PATCH] Factor golint validation into a script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This script (scripts/golint.sh) handily exempts vendored and generated files. Sample usage: * “scripts/goimports.sh -d -e” → show full diff * “scripts/goimports.sh -w” → fix files in-place --- scripts/golint.sh | 8 ++++++++ scripts/travis_checker.sh | 8 ++------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100755 scripts/golint.sh diff --git a/scripts/golint.sh b/scripts/golint.sh new file mode 100755 index 0000000000..f6327f1733 --- /dev/null +++ b/scripts/golint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +unset -v progdir +case "${0}" in +*/*) progdir="${0%/*}";; +*) progdir=.;; +esac +"${progdir}/list_harmony_go_files.sh" | "${progdir}/dirnames.sh" | \ + sort -u -t/ | xargs golint "$@" diff --git a/scripts/travis_checker.sh b/scripts/travis_checker.sh index 240c205670..9f6cda5558 100755 --- a/scripts/travis_checker.sh +++ b/scripts/travis_checker.sh @@ -1,6 +1,6 @@ #!/bin/bash -unset -v ok tmpdir go_dirs goimports_output golint_output progdir +unset -v ok tmpdir goimports_output golint_output progdir ok=true case "${0}" in @@ -14,10 +14,6 @@ tmpdir= trap 'case "${tmpdir}" in ?*) rm -rf "${tmpdir}";; esac' EXIT tmpdir=$(mktemp -d) - -go_dirs="${tmpdir}/go_dirs.txt" -"${progdir}/list_harmony_go_files.sh" | "${progdir}/dirnames.sh" | sort -u -t/ > "${go_dirs}" - echo "Running go test..." if go test -v -count=1 ./... then @@ -29,7 +25,7 @@ fi echo "Running golint..." golint_output="${tmpdir}/golint_output.txt" -if xargs golint -set_exit_status < "${go_dirs}" > "${golint_output}" 2>&1 +if "${progdir}/golint.sh" -set_exit_status > "${golint_output}" 2>&1 then echo "golint passed." else