mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
make pre-commit more portable (#880)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
@@ -12,42 +12,42 @@ cd "$REPO_ROOT"
|
|||||||
STAGED_CORE_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep '^core/' || true)
|
STAGED_CORE_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep '^core/' || true)
|
||||||
|
|
||||||
if [[ -n "$STAGED_CORE_FILES" ]]; then
|
if [[ -n "$STAGED_CORE_FILES" ]]; then
|
||||||
echo "Go files staged in core/, running CI checks..."
|
echo "Go files staged in core/, running CI checks..."
|
||||||
cd "$REPO_ROOT/core"
|
cd "$REPO_ROOT/core"
|
||||||
|
|
||||||
# Format check
|
# Format check
|
||||||
echo " Checking gofmt..."
|
echo " Checking gofmt..."
|
||||||
UNFORMATTED=$(gofmt -s -l . 2>/dev/null || true)
|
UNFORMATTED=$(gofmt -s -l . 2>/dev/null || true)
|
||||||
if [[ -n "$UNFORMATTED" ]]; then
|
if [[ -n "$UNFORMATTED" ]]; then
|
||||||
echo "The following files are not formatted:"
|
echo "The following files are not formatted:"
|
||||||
echo "$UNFORMATTED"
|
echo "$UNFORMATTED"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Run: cd core && gofmt -s -w ."
|
echo "Run: cd core && gofmt -s -w ."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# golangci-lint
|
# golangci-lint
|
||||||
if command -v golangci-lint &>/dev/null; then
|
if command -v golangci-lint &>/dev/null; then
|
||||||
echo " Running golangci-lint..."
|
echo " Running golangci-lint..."
|
||||||
golangci-lint run ./...
|
golangci-lint run ./...
|
||||||
else
|
else
|
||||||
echo " Warning: golangci-lint not installed, skipping lint"
|
echo " Warning: golangci-lint not installed, skipping lint"
|
||||||
echo " Install: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"
|
echo " Install: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
echo " Running tests..."
|
echo " Running tests..."
|
||||||
go test ./... > /dev/null
|
go test ./... >/dev/null
|
||||||
|
|
||||||
# Build checks
|
# Build checks
|
||||||
echo " Building..."
|
echo " Building..."
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
go build -buildvcs=false -o bin/dms ./cmd/dms
|
go build -buildvcs=false -o bin/dms ./cmd/dms
|
||||||
go build -buildvcs=false -o bin/dms-distro -tags distro_binary ./cmd/dms
|
go build -buildvcs=false -o bin/dms-distro -tags distro_binary ./cmd/dms
|
||||||
go build -buildvcs=false -o bin/dankinstall ./cmd/dankinstall
|
go build -buildvcs=false -o bin/dankinstall ./cmd/dankinstall
|
||||||
|
|
||||||
echo "All Go CI checks passed!"
|
echo "All Go CI checks passed!"
|
||||||
cd "$REPO_ROOT"
|
cd "$REPO_ROOT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user