Skip to content

Commit f178ef4

Browse files
authored
Merge branch 'main' into main
2 parents 4b3b828 + e35f8e1 commit f178ef4

File tree

458 files changed

+12690
-1651
lines changed

Some content is hidden

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

458 files changed

+12690
-1651
lines changed

.drone.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ steps:
2525
- make deps-frontend
2626

2727
- name: deps-backend
28-
image: golang:1.19
28+
image: golang:1.20
2929
pull: always
3030
commands:
3131
- make deps-backend
@@ -88,7 +88,7 @@ steps:
8888
depends_on: [deps-frontend]
8989

9090
- name: checks-backend
91-
image: golang:1.19
91+
image: golang:1.20
9292
commands:
9393
- make --always-make checks-backend # ensure the 'go-licenses' make target runs
9494
depends_on: [deps-backend]
@@ -109,7 +109,7 @@ steps:
109109
depends_on: [deps-frontend]
110110

111111
- name: build-backend-no-gcc
112-
image: golang:1.18 # this step is kept as the lowest version of golang that we support
112+
image: golang:1.19 # this step is kept as the lowest version of golang that we support
113113
pull: always
114114
environment:
115115
GO111MODULE: on
@@ -122,7 +122,7 @@ steps:
122122
path: /go
123123

124124
- name: build-backend-arm64
125-
image: golang:1.19
125+
image: golang:1.20
126126
environment:
127127
GO111MODULE: on
128128
GOPROXY: https://goproxy.io
@@ -138,7 +138,7 @@ steps:
138138
path: /go
139139

140140
- name: build-backend-windows
141-
image: golang:1.19
141+
image: golang:1.20
142142
environment:
143143
GO111MODULE: on
144144
GOPROXY: https://goproxy.io
@@ -153,7 +153,7 @@ steps:
153153
path: /go
154154

155155
- name: build-backend-386
156-
image: golang:1.19
156+
image: golang:1.20
157157
environment:
158158
GO111MODULE: on
159159
GOPROXY: https://goproxy.io
@@ -247,7 +247,7 @@ steps:
247247
- pull_request
248248

249249
- name: deps-backend
250-
image: golang:1.19
250+
image: golang:1.20
251251
pull: always
252252
commands:
253253
- make deps-backend
@@ -364,7 +364,7 @@ steps:
364364
path: /go
365365

366366
- name: generate-coverage
367-
image: golang:1.19
367+
image: golang:1.20
368368
commands:
369369
- make coverage
370370
environment:
@@ -440,7 +440,7 @@ steps:
440440
- pull_request
441441

442442
- name: deps-backend
443-
image: golang:1.19
443+
image: golang:1.20
444444
pull: always
445445
commands:
446446
- make deps-backend
@@ -557,7 +557,7 @@ steps:
557557
- name: test-e2e
558558
image: mcr.microsoft.com/playwright:v1.29.2-focal
559559
commands:
560-
- curl -sLO https://go.dev/dl/go1.19.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.19.linux-amd64.tar.gz
560+
- curl -sLO https://go.dev/dl/go1.20.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.20.linux-amd64.tar.gz
561561
- groupadd --gid 1001 gitea && useradd -m --gid 1001 --uid 1001 gitea
562562
- apt-get -qq update && apt-get -qqy install build-essential
563563
- export TEST_PGSQL_SCHEMA=''
@@ -656,7 +656,7 @@ trigger:
656656

657657
steps:
658658
- name: download
659-
image: golang:1.19
659+
image: golang:1.20
660660
pull: always
661661
commands:
662662
- timeout -s ABRT 40m make generate-license generate-gitignore
@@ -720,7 +720,7 @@ steps:
720720
- make deps-frontend
721721

722722
- name: deps-backend
723-
image: golang:1.19
723+
image: golang:1.20
724724
pull: always
725725
commands:
726726
- make deps-backend
@@ -729,7 +729,7 @@ steps:
729729
path: /go
730730

731731
- name: static
732-
image: techknowlogick/xgo:go-1.19.x
732+
image: techknowlogick/xgo:go-1.20.x
733733
pull: always
734734
commands:
735735
# Upgrade to node 18 once https://github.com/techknowlogick/xgo/issues/163 is resolved
@@ -841,7 +841,7 @@ steps:
841841
- make deps-frontend
842842

843843
- name: deps-backend
844-
image: golang:1.19
844+
image: golang:1.20
845845
pull: always
846846
commands:
847847
- make deps-backend
@@ -850,7 +850,7 @@ steps:
850850
path: /go
851851

852852
- name: static
853-
image: techknowlogick/xgo:go-1.19.x
853+
image: techknowlogick/xgo:go-1.20.x
854854
pull: always
855855
commands:
856856
# Upgrade to node 18 once https://github.com/techknowlogick/xgo/issues/163 is resolved
@@ -932,7 +932,7 @@ trigger:
932932

933933
steps:
934934
- name: build-docs
935-
image: golang:1.19
935+
image: golang:1.20
936936
commands:
937937
- cd docs
938938
- make trans-copy clean build

.golangci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ linters:
2828
fast: false
2929

3030
run:
31-
go: 1.19
31+
go: 1.20
3232
timeout: 10m
3333
skip-dirs:
3434
- node_modules
@@ -74,7 +74,7 @@ linters-settings:
7474
- name: modifies-value-receiver
7575
gofumpt:
7676
extra-rules: true
77-
lang-version: "1.19"
77+
lang-version: "1.20"
7878
depguard:
7979
list-type: denylist
8080
# Check the list against standard lib.
@@ -84,6 +84,7 @@ linters-settings:
8484
- github.com/unknwon/com: "use gitea's util and replacements"
8585
- io/ioutil: "use os or io instead"
8686
- golang.org/x/exp: "it's experimental and unreliable."
87+
- code.gitea.io/gitea/modules/git/internal: "do not use the internal package, use AddXxx function instead"
8788

8889
issues:
8990
max-issues-per-linter: 0

CONTRIBUTING.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -267,26 +267,10 @@ with the rest of the summary matching the original PR. Similarly for frontports
267267

268268
---
269269

270-
The below is a script that may be helpful in creating backports. YMMV.
270+
A command to help create backports can be found in `contrib/backport` and can be installed (from inside the gitea repo root directory) using:
271271

272272
```bash
273-
#!/bin/sh
274-
PR="$1"
275-
SHA="$2"
276-
VERSION="$3"
277-
278-
if [ -z "$SHA" ]; then
279-
SHA=$(gh api /repos/go-gitea/gitea/pulls/$PR -q '.merge_commit_sha')
280-
fi
281-
282-
if [ -z "$VERSION" ]; then
283-
VERSION="v1.16"
284-
fi
285-
286-
echo git checkout origin/release/"$VERSION" -b backport-$PR-$VERSION
287-
git checkout origin/release/"$VERSION" -b backport-$PR-$VERSION
288-
git cherry-pick $SHA && git commit --amend && git push zeripath backport-$PR-$VERSION && xdg-open https://github.com/go-gitea/gitea/compare/release/"$VERSION"...zeripath:backport-$PR-$VERSION
289-
273+
go install contrib/backport/backport.go
290274
```
291275

292276
## Developer Certificate of Origin (DCO)

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Build stage
2-
FROM golang:1.19-alpine3.17 AS build-env
2+
FROM golang:1.20-alpine3.17 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}

Dockerfile.rootless

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Build stage
2-
FROM golang:1.19-alpine3.17 AS build-env
2+
FROM golang:1.20-alpine3.17 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ SHASUM ?= shasum -a 256
2323
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
2424
COMMA := ,
2525

26-
XGO_VERSION := go-1.19.x
26+
XGO_VERSION := go-1.20.x
2727

2828
AIR_PACKAGE ?= github.com/cosmtrek/[email protected]
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
3030
ERRCHECK_PACKAGE ?= github.com/kisielk/[email protected]
3131
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
32-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1
32+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.0
3333
GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3434
MISSPELL_PACKAGE ?= github.com/client9/misspell/cmd/[email protected]
3535
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]

assets/go-licenses.json

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

build/generate-go-licenses.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"encoding/json"
1010
"io/fs"
1111
"os"
12+
goPath "path"
1213
"path/filepath"
1314
"regexp"
1415
"sort"
@@ -47,13 +48,15 @@ func main() {
4748

4849
entries := []LicenseEntry{}
4950
for _, path := range paths {
51+
path := filepath.ToSlash(path)
52+
5053
licenseText, err := os.ReadFile(path)
5154
if err != nil {
5255
panic(err)
5356
}
5457

55-
path := strings.Replace(path, base+string(os.PathSeparator), "", 1)
56-
name := filepath.Dir(path)
58+
path = strings.Replace(path, base+"/", "", 1)
59+
name := goPath.Dir(path)
5760

5861
// There might be a bug somewhere in go-licenses that sometimes interprets the
5962
// root package as "." and sometimes as "code.gitea.io/gitea". Workaround by

cmd/admin.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ var (
180180
Name: "raw",
181181
Usage: "Display only the token value",
182182
},
183+
cli.StringFlag{
184+
Name: "scopes",
185+
Value: "",
186+
Usage: "Comma separated list of scopes to apply to access token",
187+
},
183188
},
184189
Action: runGenerateAccessToken,
185190
}
@@ -573,12 +578,16 @@ func runCreateUser(c *cli.Context) error {
573578
restricted = util.OptionalBoolOf(c.Bool("restricted"))
574579
}
575580

581+
// default user visibility in app.ini
582+
visibility := setting.Service.DefaultUserVisibilityMode
583+
576584
u := &user_model.User{
577585
Name: username,
578586
Email: c.String("email"),
579587
Passwd: password,
580588
IsAdmin: c.Bool("admin"),
581589
MustChangePassword: changePassword,
590+
Visibility: visibility,
582591
}
583592

584593
overwriteDefault := &user_model.CreateUserOverwriteOptions{
@@ -698,9 +707,15 @@ func runGenerateAccessToken(c *cli.Context) error {
698707
return err
699708
}
700709

710+
accessTokenScope, err := auth_model.AccessTokenScope(c.String("scopes")).Normalize()
711+
if err != nil {
712+
return err
713+
}
714+
701715
t := &auth_model.AccessToken{
702-
Name: c.String("token-name"),
703-
UID: user.ID,
716+
Name: c.String("token-name"),
717+
UID: user.ID,
718+
Scope: accessTokenScope,
704719
}
705720

706721
if err := auth_model.NewAccessToken(t); err != nil {

cmd/hook.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ Gitea or set your environment appropriately.`, "")
185185
userID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
186186
prID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPRID), 10, 64)
187187
deployKeyID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvDeployKeyID), 10, 64)
188+
actionPerm, _ := strconv.ParseInt(os.Getenv(repo_module.EnvActionPerm), 10, 64)
188189

189190
hookOptions := private.HookOptions{
190191
UserID: userID,
@@ -194,6 +195,7 @@ Gitea or set your environment appropriately.`, "")
194195
GitPushOptions: pushOptions(),
195196
PullRequestID: prID,
196197
DeployKeyID: deployKeyID,
198+
ActionPerm: int(actionPerm),
197199
}
198200

199201
scanner := bufio.NewScanner(os.Stdin)

contrib/backport/README

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
`backport`
2+
==========
3+
4+
`backport` is a command to help create backports of PRs. It backports a
5+
provided PR from main on to a released version.
6+
7+
It will create a backport branch, cherry-pick the PR's merge commit, adjust
8+
the commit message and then push this back up to your fork's remote.
9+
10+
The default version will read from `docs/config.yml`. You can override this
11+
using the option `--version`.
12+
13+
The upstream branches will be fetched, using the remote `origin`. This can
14+
be overrided using `--upstream`, and fetching can be avoided using
15+
`--no-fetch`.
16+
17+
By default the branch created will be called `backport-$PR-$VERSION`. You
18+
can override this using the option `--backport-branch`. This branch will
19+
be created from `--release-branch` which is `release/$(VERSION)`
20+
by default and will be pulled from `$(UPSTREAM)`.
21+
22+
The merge-commit as determined by the github API will be used as the SHA to
23+
cherry-pick. You can override this using `--cherry-pick`.
24+
25+
The commit message will be amended to add the `Backport` header.
26+
`--no-amend-message` can be set to stop this from happening.
27+
28+
If cherry-pick is successful the backported branch will be pushed up to your
29+
fork using your remote. These will be determined using `git remote -v`. You
30+
can set your fork name using `--fork-user` and your remote name using
31+
`--remote`. You can avoid pushing using `--no-push`.
32+
33+
If the push is successful, `xdg-open` will be called to open a backport url.
34+
You can stop this using `--no-xdg-open`.
35+
36+
Installation
37+
============
38+
39+
```bash
40+
go install contrib/backport/backport.go
41+
```

0 commit comments

Comments
 (0)