Skip to content

Commit b24db66

Browse files
authored
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.
1 parent 4266bd9 commit b24db66

File tree

2 files changed

+10
-61
lines changed

2 files changed

+10
-61
lines changed

Makefile

+10-5
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ help:
195195
@echo " - swagger-validate check if the swagger spec is valid"
196196
@echo " - golangci-lint run golangci-lint linter"
197197
@echo " - vet examines Go source code and reports suspicious constructs"
198+
@echo " - tidy run go mod tidy"
198199
@echo " - test[\#TestSpecificName] run unit test"
199200
@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
200201
@echo " - pr#<index> build and start gitea from a PR with integration test data loaded"
@@ -369,16 +370,20 @@ unit-test-coverage:
369370
@echo "Running unit-test-coverage $(GOTESTFLAGS) -tags '$(TEST_TAGS)'..."
370371
@$(GO) test $(GOTESTFLAGS) -timeout=20m -tags='$(TEST_TAGS)' -cover -coverprofile coverage.out $(GO_PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
371372

373+
.PHONY: tidy
374+
tidy:
375+
$(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2))
376+
$(GO) mod tidy -compat=$(MIN_GO_VERSION)
377+
372378
.PHONY: vendor
373-
vendor:
374-
$(GO) mod tidy && $(GO) mod vendor
379+
vendor: tidy
380+
$(GO) mod vendor
375381

376382
.PHONY: gomod-check
377-
gomod-check:
378-
@$(GO) mod tidy
383+
gomod-check: tidy
379384
@diff=$$(git diff go.sum); \
380385
if [ -n "$$diff" ]; then \
381-
echo "Please run '$(GO) mod tidy' and commit the result:"; \
386+
echo "Please run 'make tidy' and commit the result:"; \
382387
echo "$${diff}"; \
383388
exit 1; \
384389
fi

0 commit comments

Comments
 (0)