Skip to content

Commit b38d134

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: Fix sub folder in repository missing add file dropdown (go-gitea#21069) [skip ci] Updated translations via Crowdin Add missing volume to test-e2e (go-gitea#21079) Fix delete user missed some comments (go-gitea#21067) Remove insecure flag from curl (go-gitea#21074) Update curl usage in API docs (go-gitea#21071) Move go-licenses to generate and separate generate into a frontend and backend component (go-gitea#21061)
2 parents ccd705d + f1ea6c9 commit b38d134

File tree

18 files changed

+91
-42
lines changed

18 files changed

+91
-42
lines changed

.drone.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ steps:
569569
TEST_PGSQL_DBNAME: 'testgitea-e2e'
570570
DEBIAN_FRONTEND: noninteractive
571571
depends_on: [build-frontend, deps-backend]
572+
volumes:
573+
- name: deps
574+
path: /go
572575

573576
---
574577
kind: pipeline

Makefile

Lines changed: 21 additions & 6 deletions
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

Lines changed: 4 additions & 4 deletions
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:[email protected]/api/v1/users/<username>/tokens
61+
$ curl --url https://yourusername:[email protected]/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:[email protected]/api/v1/users/yourusername/tokens
73+
$ curl -H "X-Gitea-OTP: 123456" --url https://yourusername:[email protected]/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

Lines changed: 2 additions & 2 deletions
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:[email protected]/api/v1/users/yourusername/tokens
65+
$ curl --url https://yourusername:[email protected]/api/v1/users/yourusername/tokens
6666
[{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}]
6767
```
6868

models/user.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ func DeleteUser(ctx context.Context, u *user_model.User, purge bool) (err error)
102102

103103
// Delete Comments
104104
const batchSize = 50
105-
for start := 0; ; start += batchSize {
105+
for {
106106
comments := make([]*issues_model.Comment, 0, batchSize)
107-
if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, start).Find(&comments); err != nil {
107+
if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, 0).Find(&comments); err != nil {
108108
return err
109109
}
110110
if len(comments) == 0 {
@@ -202,7 +202,7 @@ func DeleteUser(ctx context.Context, u *user_model.User, purge bool) (err error)
202202
// ***** END: ExternalLoginUser *****
203203

204204
if _, err = e.ID(u.ID).Delete(new(user_model.User)); err != nil {
205-
return fmt.Errorf("Delete: %v", err)
205+
return fmt.Errorf("delete: %v", err)
206206
}
207207

208208
return nil

modules/charset/ambiguous/generate.go

Lines changed: 11 additions & 0 deletions
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

Lines changed: 11 additions & 0 deletions
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)

options/locale/locale_pt-PT.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,8 @@ settings.event_delete=Eliminar
19561956
settings.event_delete_desc=Ramo ou etiqueta eliminados.
19571957
settings.event_fork=Derivar
19581958
settings.event_fork_desc=Feita a derivação do repositório.
1959+
settings.event_wiki=Wiki
1960+
settings.event_wiki_desc=Página do wiki criada, renomeada, editada ou eliminada.
19591961
settings.event_release=Lançamento
19601962
settings.event_release_desc=Lançamento publicado, modificado ou eliminado num repositório.
19611963
settings.event_push=Enviar

services/migrations/dump.go

Lines changed: 0 additions & 1 deletion
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/home.tmpl

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -73,32 +73,33 @@
7373
</a>
7474
{{end}}
7575
<a href="{{.Repository.Link}}/find/{{.BranchNameSubURL}}" class="ui compact basic button tooltip" data-content="{{.locale.Tr "repo.find_file.go_to_file"}}">{{svg "octicon-file-moved" 15}}</a>
76-
{{if or .CanAddFile .CanUploadFile}}
77-
<button class="ui basic small compact dropdown jump icon button mr-2">
78-
<span class="text">{{.locale.Tr "repo.editor.add_file"}}</span>
79-
<div class="menu">
80-
{{if .Repository.CanEnableEditor}}
81-
{{if .CanAddFile}}
82-
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
83-
{{.locale.Tr "repo.editor.new_file"}}
84-
</a>
85-
{{end}}
86-
{{if .CanUploadFile}}
87-
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
88-
{{.locale.Tr "repo.editor.upload_file"}}
89-
</a>
90-
{{end}}
91-
{{if .CanAddFile}}
92-
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
93-
{{.locale.Tr "repo.editor.patch"}}
94-
</a>
95-
{{end}}
76+
{{end}}
77+
{{if or .CanAddFile .CanUploadFile}}
78+
<button class="ui basic small compact dropdown jump icon button mr-2">
79+
<span class="text">{{.locale.Tr "repo.editor.add_file"}}</span>
80+
<div class="menu">
81+
{{if .Repository.CanEnableEditor}}
82+
{{if .CanAddFile}}
83+
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
84+
{{.locale.Tr "repo.editor.new_file"}}
85+
</a>
9686
{{end}}
97-
</div>
98-
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
99-
</button>
100-
{{end}}
101-
{{else}}
87+
{{if .CanUploadFile}}
88+
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
89+
{{.locale.Tr "repo.editor.upload_file"}}
90+
</a>
91+
{{end}}
92+
{{if .CanAddFile}}
93+
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
94+
{{.locale.Tr "repo.editor.patch"}}
95+
</a>
96+
{{end}}
97+
{{end}}
98+
</div>
99+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
100+
</button>
101+
{{end}}
102+
{{if ne $n 0}}
102103
<span class="ui breadcrumb repo-path"><a class="section" href="{{.RepoLink}}/src/{{.BranchNameSubURL}}" title="{{.Repository.Name}}">{{EllipsisString .Repository.Name 30}}</a>{{range $i, $v := .TreeNames}}<span class="divider">/</span>{{if eq $i $l}}<span class="active section" title="{{$v}}">{{EllipsisString $v 30}}</span>{{else}}{{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{EllipsisString $v 30}}</a></span>{{end}}{{end}}</span>
103104
{{end}}
104105
</div>

templates/repo/sub_menu.tmpl

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)