From 8f059b7bafcb5024019855d474fbc789189ddf69 Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Mon, 25 Nov 2024 10:01:44 +0100 Subject: [PATCH] make make pretty actually fix imports Signed-off-by: Andres Taylor --- Makefile | 4 ++-- git-hooks/pre-commit | 8 ++++---- go/summarize/utils_test.go | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 40bfdf6..7562589 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,8 @@ clean: # Pretty: formats the code using gofumpt and goimports-reviser pretty: check-tools @echo "Running formatting tools..." - @gofumpt -l -w . >/dev/null 2>&1 || true - @goimports-reviser -project-name $$(go list -m) -rm-unused -set-alias -format . >/dev/null 2>&1 || true + @gofumpt -w . >/dev/null 2>&1 + @goimports-reviser -recursive -project-name $$(go list -m) -rm-unused -set-alias ./go >/dev/null 2>&1 # Tools installation command install-tools: diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit index 4c2b37d..83f8e1f 100755 --- a/git-hooks/pre-commit +++ b/git-hooks/pre-commit @@ -18,12 +18,12 @@ for file in $GO_FILES; do } done -# 2. Run goimports-reviser to verify formatting on changed files (without writing changes) -echo "Checking goimports-reviser formatting..." +# Check imports with goimports-reviser +echo "Checking goimports-reviser imports..." for file in $GO_FILES; do - goimports-reviser -project-name $(go list -m) -rm-unused -set-alias -format "$file" -diff >/dev/null 2>&1 + goimports-reviser -project-name $(go list -m) -rm-unused -set-alias "$file" >/dev/null 2>&1 if [[ $? -ne 0 ]]; then - echo "Error: Imports not correctly formatted in $file. Please run 'make pretty'." + echo "Error: Imports not correctly organized in $file. Please run 'make pretty'." exit 1 fi done diff --git a/go/summarize/utils_test.go b/go/summarize/utils_test.go index f2c2d09..5547fce 100644 --- a/go/summarize/utils_test.go +++ b/go/summarize/utils_test.go @@ -20,7 +20,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" )