github.com/abemedia/go-don@v0.2.2-0.20240329015135-be88e32bb73b/scripts/pre-commit.sh (about)

     1  #!/bin/bash
     2  
     3  git stash --keep-index --include-untracked --quiet
     4  
     5  exitCode=0
     6  
     7  go mod tidy || exitCode=$?
     8  golangci-lint run || exitCode=$?
     9  go test ./... || exitCode=$?
    10  
    11  if [ $exitCode -eq 0 ]; then
    12    git add .
    13  else
    14    git stash --keep-index --include-untracked --quiet && git stash drop --quiet
    15  fi
    16  
    17  git stash pop --quiet
    18  
    19  exit $exitCode