github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/scripts/git-hooks/pre-commit (about)

     1  #!/bin/sh
     2  
     3  # Check if golangci-lint is installed
     4  if ! command -v golangci-lint >/dev/null 2>&1; then
     5    echo "Error: golangci-lint is not installed. Please install it before committing."
     6    exit 1
     7  fi
     8  
     9  # Run golangci-lint
    10  golangci-lint run
    11  
    12  # Capture the exit code of golangci-lint
    13  EXIT_CODE=$?
    14  
    15  # If golangci-lint fails, prevent commit
    16  if [ $EXIT_CODE -ne 0 ]; then
    17    echo "golangci-lint found issues. Please fix them before committing."
    18    exit 1
    19  fi
    20  
    21  # If linting passes, allow commit
    22  exit 0