Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 42769da

Browse files
authored
Merge pull request #57 from xinydev/presubmit
Make error message for pre-submit check more clearly
2 parents f536e79 + eddf342 commit 42769da

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ fmt:
169169

170170
# check-fmt: Checks gofmt/go fmt has been ran. gofmt -l lists files whose formatting differs from gofmt's, so it fails if there are unformatted go code.
171171
check-fmt:
172-
@test -z $(shell gofmt -l ${GOFMT_DIRS})
172+
@if [ $(shell gofmt -l ${GOFMT_DIRS} | wc -l ) != 0 ]; then \
173+
echo "Error: there are unformatted go code, please run 'gofmt' before committing" ; \
174+
fi
173175

174176
# Run go vet against code
175177
vet:
@@ -180,7 +182,9 @@ generate: controller-gen
180182
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./api/...
181183

182184
check-generate: generate
183-
@test -z $(shell git status --untracked-files=no --porcelain)
185+
@if [ $(shell git status --untracked-files=no --porcelain | wc -l ) != 0 ]; then \
186+
echo "Error: generated files are out of sync, please run 'make generate' before committing" ; \
187+
fi
184188

185189
# Use the version of controller-gen that's checked into vendor/ (see
186190
# hack/tools.go to see how it got there).

0 commit comments

Comments
 (0)