Skip to content

Commit cee7c08

Browse files
authored
Merge branch 'main' into telackey/sort
2 parents f54af1e + ead716d commit cee7c08

File tree

133 files changed

+1604
-1129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+1604
-1129
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ insert_final_newline = false
1717

1818
[templates/swagger/v1_json.tmpl]
1919
indent_style = space
20+
insert_final_newline = false
2021

2122
[templates/user/auth/oidc_wellknown.tmpl]
2223
indent_style = space

.github/workflows/files-changed.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
8686
swagger:
8787
- "templates/swagger/v1_json.tmpl"
88+
- "templates/swagger/v1_input.json"
8889
- "Makefile"
8990
- "package.json"
9091
- "package-lock.json"

.golangci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ linters:
1919
- revive
2020
- staticcheck
2121
- stylecheck
22-
- tenv
2322
- testifylint
2423
- typecheck
2524
- unconvert
2625
- unused
2726
- unparam
27+
- usetesting
2828
- wastedassign
2929

3030
run:
@@ -102,6 +102,8 @@ linters-settings:
102102
desc: do not use the ini package, use gitea's config system instead
103103
- pkg: gitea.com/go-chi/cache
104104
desc: do not use the go-chi cache package, use gitea's cache system
105+
usetesting:
106+
os-temp-dir: true
105107

106108
issues:
107109
max-issues-per-linter: 0

CHANGELOG.md

Lines changed: 511 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ XGO_VERSION := go-1.24.x
2828
AIR_PACKAGE ?= github.com/air-verse/air@v1
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/[email protected]
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
@@ -165,10 +165,8 @@ ifdef DEPS_PLAYWRIGHT
165165
endif
166166

167167
SWAGGER_SPEC := templates/swagger/v1_json.tmpl
168-
SWAGGER_SPEC_S_TMPL := s|"basePath": *"/api/v1"|"basePath": "{{AppSubUrl \| JSEscape}}/api/v1"|g
169-
SWAGGER_SPEC_S_JSON := s|"basePath": *"{{AppSubUrl \| JSEscape}}/api/v1"|"basePath": "/api/v1"|g
168+
SWAGGER_SPEC_INPUT := templates/swagger/v1_input.json
170169
SWAGGER_EXCLUDE := code.gitea.io/sdk
171-
SWAGGER_NEWLINE_COMMAND := -e '$$a\'
172170

173171
TEST_MYSQL_HOST ?= mysql:3306
174172
TEST_MYSQL_DBNAME ?= testgitea
@@ -255,7 +253,7 @@ fmt-check: fmt
255253
@diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \
256254
if [ -n "$$diff" ]; then \
257255
echo "Please run 'make fmt' and commit the result:"; \
258-
echo "$${diff}"; \
256+
printf "%s" "$${diff}"; \
259257
exit 1; \
260258
fi
261259

@@ -271,25 +269,25 @@ endif
271269
.PHONY: generate-swagger
272270
generate-swagger: $(SWAGGER_SPEC) ## generate the swagger spec from code comments
273271

274-
$(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
275-
$(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)'
276-
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
277-
$(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
272+
$(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA) $(SWAGGER_SPEC_INPUT)
273+
$(GO) run $(SWAGGER_PACKAGE) generate spec --exclude "$(SWAGGER_EXCLUDE)" --input "$(SWAGGER_SPEC_INPUT)" --output './$(SWAGGER_SPEC)'
278274

279275
.PHONY: swagger-check
280276
swagger-check: generate-swagger
281277
@diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \
282278
if [ -n "$$diff" ]; then \
283279
echo "Please run 'make generate-swagger' and commit the result:"; \
284-
echo "$${diff}"; \
280+
printf "%s" "$${diff}"; \
285281
exit 1; \
286282
fi
287283

288284
.PHONY: swagger-validate
289285
swagger-validate: ## check if the swagger spec is valid
290-
$(SED_INPLACE) '$(SWAGGER_SPEC_S_JSON)' './$(SWAGGER_SPEC)'
286+
@# swagger "validate" requires that the "basePath" must start with a slash, but we are using Golang template "{{...}}"
287+
@$(SED_INPLACE) -E -e 's|"basePath":( *)"(.*)"|"basePath":\1"/\2"|g' './$(SWAGGER_SPEC)' # add a prefix slash to basePath
288+
@# FIXME: there are some warnings
291289
$(GO) run $(SWAGGER_PACKAGE) validate './$(SWAGGER_SPEC)'
292-
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
290+
@$(SED_INPLACE) -E -e 's|"basePath":( *)"/(.*)"|"basePath":\1"\2"|g' './$(SWAGGER_SPEC)' # remove the prefix slash from basePath
293291

294292
.PHONY: checks
295293
checks: checks-frontend checks-backend ## run various consistency checks
@@ -380,6 +378,7 @@ lint-go-gopls: ## lint go files with gopls
380378

381379
.PHONY: lint-editorconfig
382380
lint-editorconfig:
381+
@echo "Running editorconfig check..."
383382
@$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES)
384383

385384
.PHONY: lint-actions
@@ -426,7 +425,7 @@ test-check:
426425
@diff=$$(git status -s); \
427426
if [ -n "$$diff" ]; then \
428427
echo "make test-backend has changed files in the source tree:"; \
429-
echo "$${diff}"; \
428+
printf "%s" "$${diff}"; \
430429
echo "You should change the tests to create these files in a temporary directory."; \
431430
echo "Do not simply add these files to .gitignore"; \
432431
exit 1; \
@@ -463,7 +462,7 @@ tidy-check: tidy
463462
@diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \
464463
if [ -n "$$diff" ]; then \
465464
echo "Please run 'make tidy' and commit the result:"; \
466-
echo "$${diff}"; \
465+
printf "%s" "$${diff}"; \
467466
exit 1; \
468467
fi
469468

@@ -879,7 +878,7 @@ svg-check: svg
879878
@diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \
880879
if [ -n "$$diff" ]; then \
881880
echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \
882-
echo "$${diff}"; \
881+
printf "%s" "$${diff}"; \
883882
exit 1; \
884883
fi
885884

@@ -890,7 +889,7 @@ lockfile-check:
890889
if [ -n "$$diff" ]; then \
891890
echo "package-lock.json is inconsistent with package.json"; \
892891
echo "Please run 'npm install --package-lock-only' and commit the result:"; \
893-
echo "$${diff}"; \
892+
printf "%s" "$${diff}"; \
894893
exit 1; \
895894
fi
896895

0 commit comments

Comments
 (0)