1
Fork 0

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.
This commit is contained in:
silverwind 2022-05-25 02:19:13 +02:00 committed by GitHub
parent 4266bd924b
commit b24db66a5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 61 deletions

View file

@ -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