Something went wrong. Try again.
Vibe-guided bskyoauth and custom repo example code in Golang ๐ค probably not safe to use in prod
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123#!/bin/sh## Git pre-commit hook for bskyoauth# Runs code quality, security checks, and tests before allowing commit## To install: cp scripts/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit# To bypass: git commit --no-verifyset -eecho "๐ Running pre-commit checks..."echo ""# Check code formattingecho "๐ Checking code formatting..."UNFORMATTED=$(gofmt -l .)if [ -n "$UNFORMATTED" ]; then echo "" echo "โ Code is not formatted! Please run:" echo " gofmt -w ." echo "" echo "Unformatted files:" echo "$UNFORMATTED" echo "" echo "To bypass: git commit --no-verify" exit 1fiecho "โ
Code is properly formatted"echo ""# Check if golangci-lint is installedif ! command -v golangci-lint >/dev/null 2>&1; then echo "โ ๏ธ golangci-lint not found. Installing..." go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest if [ $? -ne 0 ]; then echo "โ Failed to install golangci-lint" echo " You can install it manually: https://golangci-lint.run/welcome/install/" echo " To bypass: git commit --no-verify" exit 1 fifi# Run golangci-lintecho "๐ Running golangci-lint..."GOLANGCI_LINT_PATH=$(go env GOPATH)/bin/golangci-lintif [ ! -f "$GOLANGCI_LINT_PATH" ]; then GOLANGCI_LINT_PATH="$HOME/go/bin/golangci-lint"fiif ! $GOLANGCI_LINT_PATH run --timeout=5m; then echo "" echo "โ Linting issues found! Please fix before committing." echo " Run: golangci-lint run for details" echo " To bypass: git commit --no-verify" exit 1fiecho "โ
No linting issues found"echo ""# Check if govulncheck is installedif ! command -v govulncheck >/dev/null 2>&1; then echo "โ ๏ธ govulncheck not found. Installing..." go install golang.org/x/vuln/cmd/govulncheck@latest if [ $? -ne 0 ]; then echo "โ Failed to install govulncheck" exit 1 fifi# Run govulncheckecho "๐ Running govulncheck..."GOVULNCHECK_PATH=$(go env GOPATH)/bin/govulncheckif [ ! -f "$GOVULNCHECK_PATH" ]; then GOVULNCHECK_PATH="$HOME/go/bin/govulncheck"fi$GOVULNCHECK_PATH ./... 2>&1 | grep -E "(No vulnerabilities found|Your code is affected)" || { echo "" echo "โ Vulnerabilities detected! Please fix before committing." echo " Run: govulncheck ./... for details" echo " To bypass: git commit --no-verify" exit 1}# Check if vulnerabilities were foundif $GOVULNCHECK_PATH ./... 2>&1 | grep -q "Your code is affected by [1-9]"; then echo "" echo "โ Vulnerabilities detected! Please fix before committing." echo " Run: govulncheck ./... for details" echo " To bypass: git commit --no-verify" exit 1fiecho "โ
No vulnerabilities found"echo ""# Run testsecho "๐งช Running tests..."if ! go test -race -timeout=30s ./...; then echo "" echo "โ Tests failed! Please fix before committing." echo " To bypass: git commit --no-verify" exit 1fiecho "โ
All tests passed"echo ""# Run go mod verifyecho "๐ฆ Verifying dependencies..."if ! go mod verify; then echo "" echo "โ Dependency verification failed!" echo " To bypass: git commit --no-verify" exit 1fiecho "โ
Dependencies verified"echo ""echo "โจ All pre-commit checks passed!"exit 0