Skip to content

Commit 55950d0

Browse files
authored
Merge branch 'main' into admin-delete
2 parents face1c7 + 754861a commit 55950d0

Some content is hidden

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

50 files changed

+941
-361
lines changed

.drone.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ steps:
9090
- name: checks-backend
9191
image: golang:1.19
9292
commands:
93-
- curl -sL https://deb.nodesource.com/setup_18.x | bash - && apt-get -qqy install nodejs
9493
- make checks-backend
95-
environment:
96-
DEBIAN_FRONTEND: noninteractive
9794
depends_on: [deps-backend]
9895
volumes:
9996
- name: deps
@@ -105,11 +102,16 @@ steps:
105102
- make test-frontend
106103
depends_on: [lint-frontend]
107104

105+
- name: generate-frontend
106+
image: golang:1.19
107+
commands:
108+
- make generate-frontend
109+
108110
- name: build-frontend
109111
image: node:18
110112
commands:
111113
- make frontend
112-
depends_on: [test-frontend]
114+
depends_on: [deps-frontend, generate-frontend]
113115

114116
- name: build-backend-no-gcc
115117
image: golang:1.18 # this step is kept as the lowest version of golang that we support
@@ -532,16 +534,21 @@ services:
532534

533535
steps:
534536
- name: deps-frontend
535-
image: node:16
537+
image: node:18
536538
pull: always
537539
commands:
538540
- make deps-frontend
539541

542+
- name: generate-frontend
543+
image: golang:1.18
544+
commands:
545+
- make generate-frontend
546+
540547
- name: build-frontend
541-
image: node:16
548+
image: node:18
542549
commands:
543550
- make frontend
544-
depends_on: [deps-frontend]
551+
depends_on: [deps-frontend, generate-frontend]
545552

546553
- name: deps-backend
547554
image: golang:1.18
@@ -554,7 +561,7 @@ steps:
554561

555562
# TODO: We should probably build all dependencies into a test image
556563
- name: test-e2e
557-
image: mcr.microsoft.com/playwright:v1.23.1-focal
564+
image: mcr.microsoft.com/playwright:v1.24.0-focal
558565
commands:
559566
- curl -sLO https://go.dev/dl/go1.18.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.18.linux-amd64.tar.gz
560567
- groupadd --gid 1001 gitea && useradd -m --gid 1001 --uid 1001 gitea
@@ -569,6 +576,9 @@ steps:
569576
TEST_PGSQL_DBNAME: 'testgitea-e2e'
570577
DEBIAN_FRONTEND: noninteractive
571578
depends_on: [build-frontend, deps-backend]
579+
volumes:
580+
- name: deps
581+
path: /go
572582

573583
---
574584
kind: pipeline

Makefile

Lines changed: 30 additions & 14 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
@@ -205,7 +210,7 @@ help:
205210
@echo " - golangci-lint run golangci-lint linter"
206211
@echo " - go-licenses regenerate go licenses"
207212
@echo " - vet examines Go source code and reports suspicious constructs"
208-
@echo " - tidy run go mod tidy and regenerate go licenses"
213+
@echo " - tidy run go mod tidy"
209214
@echo " - test[\#TestSpecificName] run unit test"
210215
@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
211216
@echo " - pr#<index> build and start gitea from a PR with integration test data loaded"
@@ -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,11 +405,10 @@ 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

403-
.PHONY: vendor
404-
vendor: tidy
409+
vendor: go.mod go.sum
405410
$(GO) mod vendor
411+
@touch vendor
406412

407413
.PHONY: tidy-check
408414
tidy-check: tidy
@@ -414,12 +420,12 @@ tidy-check: tidy
414420
fi
415421

416422
.PHONY: go-licenses
417-
go-licenses: assets/go-licenses.json
423+
go-licenses: $(GO_LICENSE_FILE)
418424

419-
assets/go-licenses.json: go.mod go.sum build/generate-go-licenses.js
420-
-$(GO) run $(GO_LICENSES_PACKAGE) save . --force --save_path="$(GO_LICENSE_TMP_DIR)" 2>/dev/null
421-
node build/generate-go-licenses.js "$(GO_LICENSE_TMP_DIR)" "$(GO_LICENSE_FILE)"
422-
@rm -rf "$(GO_LICENSE_TMP_DIR)"
425+
$(GO_LICENSE_FILE): go.mod go.sum
426+
-$(GO) run $(GO_LICENSES_PACKAGE) save . --force --save_path=$(GO_LICENSE_TMP_DIR) 2>/dev/null
427+
$(GO) run build/generate-go-licenses.go $(GO_LICENSE_TMP_DIR) $(GO_LICENSE_FILE)
428+
@rm -rf $(GO_LICENSE_TMP_DIR)
423429

424430
generate-ini-sqlite:
425431
sed -e 's|{{REPO_TEST_DIR}}|${REPO_TEST_DIR}|g' \
@@ -702,13 +708,23 @@ 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-frontend
721+
generate-frontend: $(GO_LICENSE_FILE)
722+
723+
.PHONY: generate-backend
724+
generate-backend: $(TAGS_PREREQ) generate-go
725+
726+
.PHONY: generate-go
727+
generate-go: $(TAGS_PREREQ)
712728
@echo "Running go generate..."
713729
@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
714730

assets/go-licenses.json

Lines changed: 362 additions & 217 deletions
Large diffs are not rendered by default.

build/generate-go-licenses.go

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright 2022 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build ignore
6+
7+
package main
8+
9+
import (
10+
"encoding/json"
11+
"io/fs"
12+
"os"
13+
"path/filepath"
14+
"regexp"
15+
"sort"
16+
"strings"
17+
)
18+
19+
// regexp is based on go-license, excluding README and NOTICE
20+
// https://github.com/google/go-licenses/blob/master/licenses/find.go
21+
var licenseRe = regexp.MustCompile(`^(?i)((UN)?LICEN(S|C)E|COPYING).*$`)
22+
23+
type LicenseEntry struct {
24+
Name string `json:"name"`
25+
Path string `json:"path"`
26+
LicenseText string `json:"licenseText"`
27+
}
28+
29+
func main() {
30+
base, out := os.Args[1], os.Args[2]
31+
32+
paths := []string{}
33+
err := filepath.WalkDir(base, func(path string, entry fs.DirEntry, err error) error {
34+
if err != nil {
35+
return err
36+
}
37+
if entry.IsDir() || !licenseRe.MatchString(entry.Name()) {
38+
return nil
39+
}
40+
paths = append(paths, path)
41+
return nil
42+
})
43+
if err != nil {
44+
panic(err)
45+
}
46+
47+
sort.Strings(paths)
48+
49+
entries := []LicenseEntry{}
50+
for _, path := range paths {
51+
licenseText, err := os.ReadFile(path)
52+
if err != nil {
53+
panic(err)
54+
}
55+
56+
path := strings.Replace(path, base+string(os.PathSeparator), "", 1)
57+
name := filepath.Dir(path)
58+
59+
// There might be a bug somewhere in go-licenses that sometimes interprets the
60+
// root package as "." and sometimes as "code.gitea.io/gitea". Workaround by
61+
// removing both of them for the sake of stable output.
62+
if name == "." || name == "code.gitea.io/gitea" {
63+
continue
64+
}
65+
66+
entries = append(entries, LicenseEntry{
67+
Name: name,
68+
Path: path,
69+
LicenseText: string(licenseText),
70+
})
71+
}
72+
73+
jsonBytes, err := json.MarshalIndent(entries, "", " ")
74+
if err != nil {
75+
panic(err)
76+
}
77+
78+
err = os.WriteFile(out, jsonBytes, 0o644)
79+
if err != nil {
80+
panic(err)
81+
}
82+
}

build/generate-go-licenses.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

docs/content/doc/advanced/logging-documentation.en-us.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ menu:
1515

1616
# Logging Configuration
1717

18-
The logging framework has been revamped in Gitea 1.9.0.
19-
2018
**Table of Contents**
2119

2220
{{< toc >}}
2321

22+
## Collecting Logs for Help
23+
24+
To collect logs for help and issue report, see [Support Options]({{< relref "doc/help/seek-help.en-us.md" >}}).
25+
2426
## Log Groups
2527

2628
The fundamental thing to be aware of in Gitea is that there are several

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

docs/content/doc/help/faq.en-us.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,9 @@ Gitea requires the system or browser to have one of the supported Emoji fonts in
392392

393393
Stdout on systemd goes to the journal by default. Try using `journalctl`, `journalctl -u gitea`, or `journalctl <path-to-gitea-binary>`.
394394

395-
Similarly stdout on docker can be viewed using `docker logs <container>`
395+
Similarly, stdout on docker can be viewed using `docker logs <container>`.
396+
397+
To collect logs for help and issue report, see [Support Options]({{< relref "doc/help/seek-help.en-us.md" >}}).
396398

397399
## Initial logging
398400

@@ -413,7 +415,7 @@ unchanged in the database schema. This may lead to warning such as:
413415
2020/08/02 11:32:29 ...rm/session_schema.go:360:Sync2() [W] Table user Column keep_activity_private db default is , struct default is 0
414416
```
415417

416-
These can safely be ignored but you may able to stop these warnings by getting Gitea to recreate these tables using:
418+
These can safely be ignored, but you are able to stop these warnings by getting Gitea to recreate these tables using:
417419

418420
```
419421
gitea doctor recreate-table user

0 commit comments

Comments
 (0)