Skip to content

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed
 

‎Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ setup-pre-commit:
317317
@cp .git/hooks/pre-commit .git/hooks/pre-commit.bak 2>/dev/null || true
318318
@echo "Installing pre-commit hook..."
319319
@ln -sf ../../scripts/hooks/pre-commit.sh .git/hooks/pre-commit
320+
@echo "Pre-commit hook was installed at .git/hooks/pre-commit"
320321

321322
#? lint: Run golangci-lint on all modules
322323
lint:

‎scripts/hooks/pre-commit.sh

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ function check_golangci_lint_version(){
2222
}
2323

2424
function lint_and_add_modified_go_files() {
25-
local go_files="$(git diff --name-only --diff-filter=d | grep \.go$ | grep -v \.pb\.go$)"
26-
for f in $go_files; do
27-
local dir_name="$(dirname $f)"
25+
local go_file_dirs="$(git diff --name-only --diff-filter=d | grep \.go$ | grep -v \.pb\.go$ | xargs dirname | sort | uniq)"
26+
for dir_name in $go_file_dirs; do
2827
golangci-lint run "${dir_name}" --fix --out-format=tab --issues-exit-code=0
29-
echo "adding ${f} to git index"
30-
git add $f
28+
echo "adding ${dir_name} to git index"
29+
git add $dir_name
3130
done
3231
}
3332

0 commit comments

Comments
 (0)
Please sign in to comment.