github.com/linuxboot/fiano@v1.2.0/scripts/pre-commit (about) 1 # Copyright 2018 the LinuxBoot Authors. All rights reserved 2 # Use of this source code is governed by a BSD-style 3 # license that can be found in the LICENSE file. 4 5 #!/bin/bash 6 7 set -e 8 9 echo "Running Pre-Commit" 10 11 FILES=`git diff --diff-filter=AM --staged --name-only | grep '.*\.go' | cat` 12 13 if [ -z "$FILES" ]; 14 then 15 echo "No go files to check. Skipping." 16 exit 0 17 fi 18 19 gofmt -w -s $FILES 20 echo $FILES | xargs -n 1 golint -set_exit_status 21 go vet ./... 22 23 # Check it builds 24 25 for x in $(ls cmds); do 26 (cd cmds/$x && go build .) 27 done 28 29 # Check tests 30 31 go test ./... 32 echo "Pre-Commit Passed"