mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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:
15
Makefile
15
Makefile
@@ -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
|
||||
|
Reference in New Issue
Block a user