Skip to content

Commit 70778ab

Browse files
authored
Merge branch 'main' into lunny/fix_delete_user
2 parents 8a0f117 + b42aaf2 commit 70778ab

File tree

14 files changed

+57
-14
lines changed

14 files changed

+57
-14
lines changed

Makefile

+21-6
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ WEBPACK_DEST_ENTRIES := public/js public/css public/fonts public/img/webpack pub
111111
BINDATA_DEST := modules/public/bindata.go modules/options/bindata.go modules/templates/bindata.go
112112
BINDATA_HASH := $(addsuffix .hash,$(BINDATA_DEST))
113113

114+
GENERATED_GO_DEST := modules/charset/invisible_gen.go modules/charset/ambiguous_gen.go
115+
114116
SVG_DEST_DIR := public/img/svg
115117

116118
AIR_TMP_DIR := .air
@@ -130,9 +132,12 @@ GO_DIRS := cmd tests models modules routers build services tools
130132

131133
GO_SOURCES := $(wildcard *.go)
132134
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" -not -path modules/options/bindata.go -not -path modules/public/bindata.go -not -path modules/templates/bindata.go)
135+
GO_SOURCES += $(GENERATED_GO_DEST)
136+
GO_SOURCES_NO_BINDATA := $(GO_SOURCES)
133137

134138
ifeq ($(filter $(TAGS_SPLIT),bindata),bindata)
135139
GO_SOURCES += $(BINDATA_DEST)
140+
GENERATED_GO_DEST += $(BINDATA_DEST)
136141
endif
137142

138143
# Force installation of playwright dependencies by setting this flag
@@ -259,7 +264,7 @@ clean:
259264
fmt:
260265
@MISSPELL_PACKAGE=$(MISSPELL_PACKAGE) GOFUMPT_PACKAGE=$(GOFUMPT_PACKAGE) $(GO) run build/code-batch-process.go gitea-fmt -w '{file-list}'
261266
$(eval TEMPLATES := $(shell find templates -type f -name '*.tmpl'))
262-
@# strip whitespace after '{{' and before `}}` unless there is only whitespace before it
267+
@# strip whitespace after '{{' and before `}}` unless there is only whitespace before it
263268
@$(SED_INPLACE) -e 's/{{[ ]\{1,\}/{{/g' -e '/^[ ]\{1,\}}}/! s/[ ]\{1,\}}}/}}/g' $(TEMPLATES)
264269

265270
.PHONY: vet
@@ -278,7 +283,9 @@ TAGS_PREREQ := $(TAGS_EVIDENCE)
278283
endif
279284

280285
.PHONY: generate-swagger
281-
generate-swagger:
286+
generate-swagger: $(SWAGGER_SPEC)
287+
288+
$(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
282289
$(GO) run $(SWAGGER_PACKAGE) generate spec -x "$(SWAGGER_EXCLUDE)" -o './$(SWAGGER_SPEC)'
283290
$(SED_INPLACE) '$(SWAGGER_SPEC_S_TMPL)' './$(SWAGGER_SPEC)'
284291
$(SED_INPLACE) $(SWAGGER_NEWLINE_COMMAND) './$(SWAGGER_SPEC)'
@@ -398,7 +405,6 @@ unit-test-coverage:
398405
tidy:
399406
$(eval MIN_GO_VERSION := $(shell grep -Eo '^go\s+[0-9]+\.[0-9.]+' go.mod | cut -d' ' -f2))
400407
$(GO) mod tidy -compat=$(MIN_GO_VERSION)
401-
@$(MAKE) --no-print-directory assets/go-licenses.json
402408

403409
.PHONY: vendor
404410
vendor: tidy
@@ -702,16 +708,25 @@ install: $(wildcard *.go)
702708
build: frontend backend
703709

704710
.PHONY: frontend
705-
frontend: $(WEBPACK_DEST)
711+
frontend: generate-frontend $(WEBPACK_DEST)
706712

707713
.PHONY: backend
708-
backend: go-check generate $(EXECUTABLE)
714+
backend: go-check generate-backend $(EXECUTABLE)
709715

716+
# We generate the backend before the frontend in case we in future we want to generate things in the frontend from generated files in backend
710717
.PHONY: generate
711-
generate: $(TAGS_PREREQ)
718+
generate: generate-backend generate-frontend
719+
720+
.PHONY: generate-backend
721+
generate-backend: $(TAGS_PREREQ) generate-go
722+
723+
generate-go: $(TAGS_PREREQ)
712724
@echo "Running go generate..."
713725
@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
714726

727+
.PHONY: generate-frontend
728+
generate-frontend: $(TAGS_PREREQ) go-licenses
729+
715730
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
716731
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
717732

docs/content/doc/developers/api-usage.en-us.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Note that `/users/:name/tokens` is a special endpoint and requires you
4949
to authenticate using `BasicAuth` and a password, as follows:
5050

5151
```sh
52-
$ curl -XPOST -H "Content-Type: application/json" -k -d '{"name":"test"}' -u username:password https://gitea.your.host/api/v1/users/<username>/tokens
52+
$ curl -H "Content-Type: application/json" -d '{"name":"test"}' -u username:password https://gitea.your.host/api/v1/users/<username>/tokens
5353
{"id":1,"name":"test","sha1":"9fcb1158165773dd010fca5f0cf7174316c3e37d","token_last_eight":"16c3e37d"}
5454
```
5555

@@ -58,7 +58,7 @@ plain-text. It will not be displayed when listing tokens with a `GET`
5858
request; e.g.
5959

6060
```sh
61-
$ curl --request GET --url https://yourusername:password@gitea.your.host/api/v1/users/<username>/tokens
61+
$ curl --url https://yourusername:password@gitea.your.host/api/v1/users/<username>/tokens
6262
[{"name":"test","sha1":"","token_last_eight:"........":},{"name":"dev","sha1":"","token_last_eight":"........"}]
6363
```
6464
@@ -70,7 +70,7 @@ is where you'd place the code from your authenticator.
7070
Here is how the request would look like in curl:
7171
7272
```sh
73-
$ curl -H "X-Gitea-OTP: 123456" --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens
73+
$ curl -H "X-Gitea-OTP: 123456" --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens
7474
```
7575
7676
You can also create an API key token via your Gitea installation's web
@@ -96,7 +96,7 @@ Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675
9696
In a `curl` command, for instance, this would look like:
9797
9898
```sh
99-
curl -X POST "http://localhost:4000/api/v1/repos/test1/test1/issues" \
99+
curl "http://localhost:4000/api/v1/repos/test1/test1/issues" \
100100
-H "accept: application/json" \
101101
-H "Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675" \
102102
-H "Content-Type: application/json" -d "{ \"body\": \"testing\", \"title\": \"test 20\"}" -i

docs/content/doc/developers/api-usage.zh-cn.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675
4646
`curl` 命令为例,它会以如下形式携带在请求中:
4747

4848
```
49-
curl -X POST "http://localhost:4000/api/v1/repos/test1/test1/issues" \
49+
curl "http://localhost:4000/api/v1/repos/test1/test1/issues" \
5050
-H "accept: application/json" \
5151
-H "Authorization: token 65eaa9c8ef52460d22a93307fe0aee76289dc675" \
5252
-H "Content-Type: application/json" -d "{ \"body\": \"testing\", \"title\": \"test 20\"}" -i
@@ -62,7 +62,7 @@ curl -X POST "http://localhost:4000/api/v1/repos/test1/test1/issues" \
6262
### 使用 Basic authentication 认证:
6363

6464
```
65-
$ curl --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens
65+
$ curl --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens
6666
[{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}]
6767
```
6868

modules/charset/ambiguous/generate.go

+11
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,17 @@ func runTemplate(t *template.Template, filename string, data interface{}) error
110110
verbosef("Bad source:\n%s", buf.String())
111111
return fmt.Errorf("unable to format source: %w", err)
112112
}
113+
114+
old, err := os.ReadFile(filename)
115+
if err != nil && !os.IsNotExist(err) {
116+
return fmt.Errorf("failed to read old file %s because %w", filename, err)
117+
} else if err == nil {
118+
if bytes.Equal(bs, old) {
119+
// files are the same don't rewrite it.
120+
return nil
121+
}
122+
}
123+
113124
file, err := os.Create(filename)
114125
if err != nil {
115126
return fmt.Errorf("failed to create file %s because %w", filename, err)

modules/charset/invisible/generate.go

+11
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ func runTemplate(t *template.Template, filename string, data interface{}) error
6363
verbosef("Bad source:\n%s", buf.String())
6464
return fmt.Errorf("unable to format source: %w", err)
6565
}
66+
67+
old, err := os.ReadFile(filename)
68+
if err != nil && !os.IsNotExist(err) {
69+
return fmt.Errorf("failed to read old file %s because %w", filename, err)
70+
} else if err == nil {
71+
if bytes.Equal(bs, old) {
72+
// files are the same don't rewrite it.
73+
return nil
74+
}
75+
}
76+
6677
file, err := os.Create(filename)
6778
if err != nil {
6879
return fmt.Errorf("failed to create file %s because %w", filename, err)

services/migrations/dump.go

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"code.gitea.io/gitea/modules/structs"
2727

2828
"github.com/google/uuid"
29-
3029
"gopkg.in/yaml.v2"
3130
)
3231

templates/repo/sub_menu.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
</div>
4040
<a class="ui segment language-stats">
4141
{{range .LanguageStats}}
42-
<div class="bar tooltip" style="width: {{.Percentage}}%; background-color: {{.Color}}" data-placement="top" data-content={{ .Language }}>&nbsp;</div>
42+
<div class="bar tooltip" style="width: {{.Percentage}}%; background-color: {{.Color}}" data-placement="top" data-content={{.Language}}>&nbsp;</div>
4343
{{end}}
4444
</a>
4545
{{end}}

tests/integration/compare_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"testing"
1111

1212
"code.gitea.io/gitea/tests"
13+
1314
"github.com/stretchr/testify/assert"
1415
)
1516

tests/integration/cors_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010

1111
"code.gitea.io/gitea/tests"
12+
1213
"github.com/stretchr/testify/assert"
1314
)
1415

tests/integration/nonascii_branches_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"testing"
1212

1313
"code.gitea.io/gitea/tests"
14+
1415
"github.com/stretchr/testify/assert"
1516
)
1617

tests/integration/pull_compare_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010

1111
"code.gitea.io/gitea/tests"
12+
1213
"github.com/stretchr/testify/assert"
1314
)
1415

tests/integration/pull_create_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"testing"
1414

1515
"code.gitea.io/gitea/tests"
16+
1617
"github.com/stretchr/testify/assert"
1718
)
1819

tests/integration/repo_commits_search_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"testing"
1212

1313
"code.gitea.io/gitea/tests"
14+
1415
"github.com/stretchr/testify/assert"
1516
)
1617

tests/integration/view_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010

1111
"code.gitea.io/gitea/tests"
12+
1213
"github.com/stretchr/testify/assert"
1314
)
1415

0 commit comments

Comments
 (0)