github.com/npaton/distribution@v2.3.1-rc.0+incompatible/project/hooks/pre-commit (about)

     1  #!/bin/sh
     2  
     3  REPO_ROOT=$(git rev-parse --show-toplevel)
     4  RESOLVE_REPO_ROOT_STATUS=$?
     5  if [ "$RESOLVE_REPO_ROOT_STATUS" -ne "0" ]; then
     6  	printf "Unable to resolve repository root. Error:\n%s\n" "$RESOLVE_REPO_ROOT_STATUS" > /dev/stderr
     7  	exit $RESOLVE_REPO_ROOT_STATUS
     8  fi
     9  
    10  cd $REPO_ROOT
    11  
    12  GOFMT_ERRORS=$(gofmt -s -l . 2>&1)
    13  if [ -n "$GOFMT_ERRORS" ]; then
    14  	printf 'gofmt failed for the following files:\n%s\n\nPlease run "gofmt -s -l ." in the root of your repository before committing\n' "$GOFMT_ERRORS" > /dev/stderr
    15  	exit 1
    16  fi
    17  
    18  GOLINT_ERRORS=$(golint ./... 2>&1)
    19  if [ -n "$GOLINT_ERRORS" ]; then
    20  	printf "golint failed with the following errors:\n%s\n" "$GOLINT_ERRORS" > /dev/stderr
    21  	exit 1
    22  fi
    23  
    24  GOVET_ERRORS=$(go vet ./... 2>&1)
    25  GOVET_STATUS=$?
    26  if [ "$GOVET_STATUS" -ne "0" ]; then
    27  	printf "govet failed with the following errors:\n%s\n" "$GOVET_ERRORS" > /dev/stderr
    28  	exit $GOVET_STATUS
    29  fi