diff options
author | silverwind <me@silverwind.io> | 2022-05-25 02:19:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-24 20:19:13 -0400 |
commit | b24db66a5fc5da501efd7e7e76776503fb906b1d (patch) | |
tree | 79db2803f6c2c52635682945fee450917d29f02f /Makefile | |
parent | 4266bd924bb8fff20271c17f8989b39b04ef6673 (diff) | |
download | gitea-b24db66a5fc5da501efd7e7e76776503fb906b1d.tar.gz gitea-b24db66a5fc5da501efd7e7e76776503fb906b1d.zip |
Add 'make tidy' (#19800)
Convenience command to run 'go mod tidy'. The compat flag is set to the
minimum supported go version instead of min version minus one which is
go's default, which eliminated some checksums in go.sum as a result.
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -195,6 +195,7 @@ help: @echo " - swagger-validate check if the swagger spec is valid" @echo " - golangci-lint run golangci-lint linter" @echo " - vet examines Go source code and reports suspicious constructs" + @echo " - tidy run go mod tidy" @echo " - test[\#TestSpecificName] run unit test" @echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite" @echo " - pr#<index> build and start gitea from a PR with integration test data loaded" @@ -369,16 +370,20 @@ unit-test-coverage: @echo "Running unit-test-coverage $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..." @$(GO) test $(GOTESTFLAGS) -timeout=20m -tags='$(TEST_TAGS)' -cover -coverprofile coverage.out $(GO_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1 +.PHONY: tidy +tidy: + $(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2)) + $(GO) mod tidy -compat=$(MIN_GO_VERSION) + .PHONY: vendor -vendor: - $(GO) mod tidy && $(GO) mod vendor +vendor: tidy + $(GO) mod vendor .PHONY: gomod-check -gomod-check: - @$(GO) mod tidy +gomod-check: tidy @diff=$$(git diff go.sum); \ if [ -n "$$diff" ]; then \ - echo "Please run '$(GO) mod tidy' and commit the result:"; \ + echo "Please run 'make tidy' and commit the result:"; \ echo "$${diff}"; \ exit 1; \ fi |