Skip to content

Commit 49aca08

Browse files
committed
Merge branch 'main' of https://github.com/go-gitea/gitea into feature-cran
2 parents 6b85c09 + 22fec16 commit 49aca08

File tree

737 files changed

+5354
-12198
lines changed

Some content is hidden

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

737 files changed

+5354
-12198
lines changed

.drone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ steps:
726726

727727
# TODO: We should probably build all dependencies into a test image
728728
- name: test-e2e
729-
image: mcr.microsoft.com/playwright:v1.29.2-focal
729+
image: mcr.microsoft.com/playwright:v1.31.2-focal
730730
commands:
731731
- curl -sLO https://go.dev/dl/go1.20.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.20.linux-amd64.tar.gz
732732
- groupadd --gid 1001 gitea && useradd -m --gid 1001 --uid 1001 gitea
@@ -1129,7 +1129,7 @@ trigger:
11291129

11301130
steps:
11311131
- name: build-docs
1132-
image: gitea/test_env:linux-1.20-amd64
1132+
image: gitea/test_env:linux-1.20-arm64
11331133
commands:
11341134
- cd docs
11351135
- make trans-copy clean build

.gitpod.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ tasks:
2424
make watch-frontend
2525
openMode: split-right
2626
- name: Run docs
27-
before: sudo bash -c "$(grep 'https://github.com/gohugoio/hugo/releases/download' Makefile | tr -d '\')" # install hugo
28-
command: cd docs && make clean update && hugo server -D -F --baseUrl $(gp url 1313) --liveReloadPort=443 --appendPort=false --bind=0.0.0.0
27+
command: |
28+
gp sync-await setup
29+
cd docs
30+
make clean update
31+
hugo server -D -F --baseUrl $(gp url 1313) --liveReloadPort=443 --appendPort=false --bind=0.0.0.0
2932
openMode: split-right
3033

3134
vscode:

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ fund=false
33
update-notifier=false
44
package-lock=true
55
save-exact=true
6+
lockfile-version=3

CHANGELOG.md

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

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Kees de Vries <[email protected]> (@Bwko)
55
Kim Carlbäcker <[email protected]> (@bkcsoft)
66
LefsFlare <[email protected]> (@LefsFlarey)
77
Lunny Xiao <[email protected]> (@lunny)
8-
Matthias Loibl <[email protected]> (@metalmatze)
98
Rachid Zarouali <[email protected]> (@xinity)
109
Rémy Boulanouar <[email protected]> (@DblK)
1110
Sandro Santilli <[email protected]> (@strk)

Makefile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ ifeq ($(RACE_ENABLED),true)
7777
endif
7878

7979
STORED_VERSION_FILE := VERSION
80+
HUGO_VERSION ?= 0.111.3
8081

8182
ifneq ($(DRONE_TAG),)
8283
VERSION ?= $(subst v,,$(DRONE_TAG))
@@ -130,7 +131,7 @@ TEST_TAGS ?= sqlite sqlite_unlock_notify
130131

131132
TAR_EXCLUDES := .git data indexers queues log node_modules $(EXECUTABLE) $(FOMANTIC_WORK_DIR)/node_modules $(DIST) $(MAKE_EVIDENCE_DIR) $(AIR_TMP_DIR) $(GO_LICENSE_TMP_DIR)
132133

133-
GO_DIRS := cmd tests models modules routers build services tools
134+
GO_DIRS := build cmd models modules routers services tests
134135
WEB_DIRS := web_src/js web_src/css
135136

136137
GO_SOURCES := $(wildcard *.go)
@@ -188,6 +189,7 @@ help:
188189
@echo " - clean delete backend and integration files"
189190
@echo " - clean-all delete backend, frontend and integration files"
190191
@echo " - deps install dependencies"
192+
@echo " - deps-docs install docs dependencies"
191193
@echo " - deps-frontend install frontend dependencies"
192194
@echo " - deps-backend install backend dependencies"
193195
@echo " - deps-tools install tool dependencies"
@@ -217,7 +219,6 @@ help:
217219
@echo " - tidy run go mod tidy"
218220
@echo " - test[\#TestSpecificName] run unit test"
219221
@echo " - test-sqlite[\#TestSpecificName] run integration test for sqlite"
220-
@echo " - pr#<index> build and start gitea from a PR with integration test data loaded"
221222

222223
.PHONY: go-check
223224
go-check:
@@ -273,7 +274,7 @@ fmt:
273274

274275
.PHONY: fmt-check
275276
fmt-check: fmt
276-
@diff=$$(git diff $(GO_SOURCES) templates $(WEB_DIRS)); \
277+
@diff=$$(git diff --color=always $(GO_SOURCES) templates $(WEB_DIRS)); \
277278
if [ -n "$$diff" ]; then \
278279
echo "Please run 'make fmt' and commit the result:"; \
279280
echo "$${diff}"; \
@@ -309,7 +310,7 @@ $(SWAGGER_SPEC): $(GO_SOURCES_NO_BINDATA)
309310

310311
.PHONY: swagger-check
311312
swagger-check: generate-swagger
312-
@diff=$$(git diff '$(SWAGGER_SPEC)'); \
313+
@diff=$$(git diff --color=always '$(SWAGGER_SPEC)'); \
313314
if [ -n "$$diff" ]; then \
314315
echo "Please run 'make generate-swagger' and commit the result:"; \
315316
echo "$${diff}"; \
@@ -351,7 +352,7 @@ lint-backend: golangci-lint vet editorconfig-checker
351352

352353
.PHONY: watch
353354
watch:
354-
bash tools/watch.sh
355+
bash build/watch.sh
355356

356357
.PHONY: watch-frontend
357358
watch-frontend: node-check node_modules
@@ -414,7 +415,7 @@ vendor: go.mod go.sum
414415

415416
.PHONY: tidy-check
416417
tidy-check: tidy
417-
@diff=$$(git diff go.mod go.sum $(GO_LICENSE_FILE)); \
418+
@diff=$$(git diff --color=always go.mod go.sum $(GO_LICENSE_FILE)); \
418419
if [ -n "$$diff" ]; then \
419420
echo "Please run 'make tidy' and commit the result:"; \
420421
echo "$${diff}"; \
@@ -815,14 +816,17 @@ release-docs: | $(DIST_DIRS) docs
815816
tar -czf $(DIST)/release/gitea-docs-$(VERSION).tar.gz -C ./docs/public .
816817

817818
.PHONY: docs
818-
docs:
819+
docs: deps-docs
820+
cd docs; make trans-copy clean build-offline;
821+
822+
.PHONY: deps-docs
823+
deps-docs:
819824
@hash hugo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
820-
curl -sL https://github.com/gohugoio/hugo/releases/download/v0.74.3/hugo_0.74.3_Linux-64bit.tar.gz | tar zxf - -C /tmp && mv /tmp/hugo /usr/bin/hugo && chmod +x /usr/bin/hugo; \
825+
curl -sL https://github.com/gohugoio/hugo/releases/download/v$(HUGO_VERSION)/hugo_$(HUGO_VERSION)_Linux-64bit.tar.gz | tar zxf - -C /tmp && mkdir -p ~/go/bin && mv /tmp/hugo ~/go/bin/hugo && chmod +x ~/go/bin/hugo; \
821826
fi
822-
cd docs; make trans-copy clean build-offline;
823827

824828
.PHONY: deps
825-
deps: deps-frontend deps-backend deps-tools
829+
deps: deps-frontend deps-backend deps-tools deps-docs
826830

827831
.PHONY: deps-frontend
828832
deps-frontend: node_modules
@@ -885,7 +889,7 @@ svg: node-check | node_modules
885889
.PHONY: svg-check
886890
svg-check: svg
887891
@git add $(SVG_DEST_DIR)
888-
@diff=$$(git diff --cached $(SVG_DEST_DIR)); \
892+
@diff=$$(git diff --color=always --cached $(SVG_DEST_DIR)); \
889893
if [ -n "$$diff" ]; then \
890894
echo "Please run 'make svg' and 'git add $(SVG_DEST_DIR)' and commit the result:"; \
891895
echo "$${diff}"; \
@@ -895,7 +899,7 @@ svg-check: svg
895899
.PHONY: lockfile-check
896900
lockfile-check:
897901
npm install --package-lock-only
898-
@diff=$$(git diff package-lock.json); \
902+
@diff=$$(git diff --color=always package-lock.json); \
899903
if [ -n "$$diff" ]; then \
900904
echo "package-lock.json is inconsistent with package.json"; \
901905
echo "Please run 'npm install --package-lock-only' and commit the result:"; \
@@ -934,10 +938,6 @@ generate-manpage:
934938
@gzip -9 man/man1/gitea.1 && echo man/man1/gitea.1.gz created
935939
@#TODO A small script that formats config-cheat-sheet.en-us.md nicely for use as a config man page
936940

937-
.PHONY: pr\#%
938-
pr\#%: clean-all
939-
$(GO) run contrib/pr/checkout.go $*
940-
941941
.PHONY: golangci-lint
942942
golangci-lint:
943943
$(GO) run $(GOLANGCI_LINT_PACKAGE) run

assets/go-licenses.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/backport-locales.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
//go:build ignore
5+
6+
package main
7+
8+
import (
9+
"fmt"
10+
"os"
11+
"os/exec"
12+
"path/filepath"
13+
"strings"
14+
15+
"gopkg.in/ini.v1"
16+
)
17+
18+
func main() {
19+
if len(os.Args) != 2 {
20+
println("usage: backport-locales <to-ref>")
21+
println("eg: backport-locales release/v1.19")
22+
os.Exit(1)
23+
}
24+
25+
ini.PrettyFormat = false
26+
mustNoErr := func(err error) {
27+
if err != nil {
28+
panic(err)
29+
}
30+
}
31+
collectInis := func(ref string) map[string]*ini.File {
32+
inis := map[string]*ini.File{}
33+
err := filepath.WalkDir("options/locale", func(path string, d os.DirEntry, err error) error {
34+
if err != nil {
35+
return err
36+
}
37+
if d.IsDir() || !strings.HasSuffix(d.Name(), ".ini") {
38+
return nil
39+
}
40+
cfg, err := ini.LoadSources(ini.LoadOptions{
41+
IgnoreInlineComment: true,
42+
UnescapeValueCommentSymbols: true,
43+
}, path)
44+
mustNoErr(err)
45+
inis[path] = cfg
46+
fmt.Printf("collecting: %s @ %s\n", path, ref)
47+
return nil
48+
})
49+
mustNoErr(err)
50+
return inis
51+
}
52+
53+
// collect new locales from current working directory
54+
inisNew := collectInis("HEAD")
55+
56+
// switch to the target ref, and collect the old locales
57+
cmd := exec.Command("git", "checkout", os.Args[1])
58+
cmd.Stdout = os.Stdout
59+
cmd.Stderr = os.Stderr
60+
mustNoErr(cmd.Run())
61+
inisOld := collectInis(os.Args[1])
62+
63+
// use old en-US as the base, and copy the new translations to the old locales
64+
enUsOld := inisOld["options/locale/locale_en-US.ini"]
65+
for path, iniOld := range inisOld {
66+
if iniOld == enUsOld {
67+
continue
68+
}
69+
iniNew := inisNew[path]
70+
if iniNew == nil {
71+
continue
72+
}
73+
for _, secEnUS := range enUsOld.Sections() {
74+
secOld := iniOld.Section(secEnUS.Name())
75+
secNew := iniNew.Section(secEnUS.Name())
76+
for _, keyEnUs := range secEnUS.Keys() {
77+
if secNew.HasKey(keyEnUs.Name()) {
78+
oldStr := secOld.Key(keyEnUs.Name()).String()
79+
newStr := secNew.Key(keyEnUs.Name()).String()
80+
// A bug: many of new translations with ";" are broken in Crowdin (due to last messy restoring)
81+
// As the broken strings are gradually fixed, this workaround check could be removed (in a few months?)
82+
if strings.Contains(oldStr, ";") && !strings.Contains(newStr, ";") {
83+
println("skip potential broken string", path, secEnUS.Name(), keyEnUs.Name())
84+
continue
85+
}
86+
secOld.Key(keyEnUs.Name()).SetValue(newStr)
87+
}
88+
}
89+
}
90+
mustNoErr(iniOld.SaveTo(path))
91+
}
92+
}

build/code-batch-process.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func newFileCollector(fileFilter string, batchSize int) (*fileCollector, error)
6565
"modules",
6666
"routers",
6767
"services",
68-
"tools",
6968
}
7069
co.includePatterns = append(co.includePatterns, regexp.MustCompile(`.*\.go$`))
7170

build/generate-svg.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,22 @@ async function processFile(file, {prefix, fullName} = {}) {
2525
if (prefix === 'octicon') name = name.replace(/-[0-9]+$/, ''); // chop of '-16' on octicons
2626
}
2727

28+
// Set the `xmlns` attribute so that the files are displayable in standalone documents
29+
// The svg backend module will strip the attribute during startup for inline display
2830
const {data} = optimize(await readFile(file, 'utf8'), {
2931
plugins: [
3032
{name: 'preset-default'},
31-
{name: 'removeXMLNS'},
3233
{name: 'removeDimensions'},
3334
{name: 'prefixIds', params: {prefix: () => name}},
3435
{name: 'addClassesToSVGElement', params: {classNames: ['svg', name]}},
35-
{name: 'addAttributesToSVGElement', params: {attributes: [{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'}]}},
36+
{
37+
name: 'addAttributesToSVGElement', params: {
38+
attributes: [
39+
{'xmlns': 'http://www.w3.org/2000/svg'},
40+
{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'},
41+
]
42+
}
43+
},
3644
],
3745
});
3846

build/test-echo.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
//go:build ignore
5+
6+
package main
7+
8+
import (
9+
"fmt"
10+
"io"
11+
"os"
12+
)
13+
14+
func main() {
15+
_, err := io.Copy(os.Stdout, os.Stdin)
16+
if err != nil {
17+
fmt.Fprintf(os.Stderr, "Error: %v", err)
18+
os.Exit(1)
19+
}
20+
}
File renamed without changes.

cmd/dump.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ func runDump(ctx *cli.Context) error {
250250

251251
if ctx.IsSet("skip-lfs-data") && ctx.Bool("skip-lfs-data") {
252252
log.Info("Skip dumping LFS data")
253+
} else if !setting.LFS.StartServer {
254+
log.Info("LFS isn't enabled. Skip dumping LFS data")
253255
} else if err := storage.LFS.IterateObjects("", func(objPath string, object storage.Object) error {
254256
info, err := object.Stat()
255257
if err != nil {
@@ -364,6 +366,8 @@ func runDump(ctx *cli.Context) error {
364366

365367
if ctx.IsSet("skip-package-data") && ctx.Bool("skip-package-data") {
366368
log.Info("Skip dumping package data")
369+
} else if !setting.Packages.Enabled {
370+
log.Info("Packages isn't enabled. Skip dumping package data")
367371
} else if err := storage.Packages.IterateObjects("", func(objPath string, object storage.Object) error {
368372
info, err := object.Stat()
369373
if err != nil {

cmd/web.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"net"
1010
"net/http"
1111
"os"
12+
"path/filepath"
13+
"strconv"
1214
"strings"
1315

1416
_ "net/http/pprof" // Used for debugging if enabled and a web server is running
@@ -25,6 +27,9 @@ import (
2527
ini "gopkg.in/ini.v1"
2628
)
2729

30+
// PIDFile could be set from build tag
31+
var PIDFile = "/run/gitea.pid"
32+
2833
// CmdWeb represents the available web sub-command.
2934
var CmdWeb = cli.Command{
3035
Name: "web",
@@ -45,7 +50,7 @@ and it takes care of all the other things for you`,
4550
},
4651
cli.StringFlag{
4752
Name: "pid, P",
48-
Value: setting.PIDFile,
53+
Value: PIDFile,
4954
Usage: "Custom pid file path",
5055
},
5156
cli.BoolFlag{
@@ -81,6 +86,22 @@ func runHTTPRedirector() {
8186
}
8287
}
8388

89+
func createPIDFile(pidPath string) {
90+
currentPid := os.Getpid()
91+
if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil {
92+
log.Fatal("Failed to create PID folder: %v", err)
93+
}
94+
95+
file, err := os.Create(pidPath)
96+
if err != nil {
97+
log.Fatal("Failed to create PID file: %v", err)
98+
}
99+
defer file.Close()
100+
if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil {
101+
log.Fatal("Failed to write PID information: %v", err)
102+
}
103+
}
104+
84105
func runWeb(ctx *cli.Context) error {
85106
if ctx.Bool("verbose") {
86107
_ = log.DelLogger("console")
@@ -107,8 +128,7 @@ func runWeb(ctx *cli.Context) error {
107128

108129
// Set pid file setting
109130
if ctx.IsSet("pid") {
110-
setting.PIDFile = ctx.String("pid")
111-
setting.WritePIDFile = true
131+
createPIDFile(ctx.String("pid"))
112132
}
113133

114134
// Perform pre-initialization

contrib/autoboot.sh

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

contrib/mysql.sql

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

0 commit comments

Comments
 (0)