Skip to content

Commit 6e6b6e6

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: docs: add `Edit this page` (go-gitea#21981) refactor some functions to support ctx as first parameter (go-gitea#21878) Remove deprecated packages & staticcheck fixes (go-gitea#22012) Add pnpm to packages/overview (go-gitea#22008) Update to Alpine 3.17 (go-gitea#21904) Update gitea-vet to check FSFE REUSE (go-gitea#22004) Multiple improvements for comment edit diff (go-gitea#21990) Remove session in api tests (go-gitea#21984) Remove duplicate "Actions" label in mobile view (go-gitea#21974) Fix generate index failure possibility on postgres (go-gitea#21998) Use path not filepath in template filenames (go-gitea#21993) Update chroma to v2.4.0 (go-gitea#22000) Util type to parse ref name (go-gitea#21969) Skip initing LFS storage if disabled (go-gitea#21996) Fix parallel creating commit status bug with tests (go-gitea#21911) Skip initing disabled storages (go-gitea#21985) Fix leaving organization bug on user settings -> orgs (go-gitea#21983) Fix typos (go-gitea#21979) Normalize `AppURL` according to RFC 3986 (go-gitea#21950)
2 parents 0261a67 + 181f4bf commit 6e6b6e6

File tree

237 files changed

+1164
-1033
lines changed

Some content is hidden

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

237 files changed

+1164
-1033
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ steps:
600600
from_secret: crowdin_key
601601

602602
- name: update
603-
image: alpine:3.13
603+
image: alpine:3.17
604604
pull: always
605605
commands:
606606
- ./build/update-locales.sh

Dockerfile

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

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}
@@ -23,7 +23,7 @@ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
2323
# Begin env-to-ini build
2424
RUN go build contrib/environment-to-ini/environment-to-ini.go
2525

26-
FROM alpine:3.16
26+
FROM alpine:3.17
2727
LABEL maintainer="maintainers@gitea.io"
2828

2929
EXPOSE 22 3000

Dockerfile.rootless

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

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}
@@ -23,7 +23,7 @@ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
2323
# Begin env-to-ini build
2424
RUN go build contrib/environment-to-ini/environment-to-ini.go
2525

26-
FROM alpine:3.16
26+
FROM alpine:3.17
2727
LABEL maintainer="maintainers@gitea.io"
2828

2929
EXPOSE 2222 3000

cmd/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ func runDeleteUser(c *cli.Context) error {
665665
} else if c.IsSet("username") {
666666
user, err = user_model.GetUserByName(ctx, c.String("username"))
667667
} else {
668-
user, err = user_model.GetUserByID(c.Int64("id"))
668+
user, err = user_model.GetUserByID(ctx, c.Int64("id"))
669669
}
670670
if err != nil {
671671
return err

custom/conf/app.example.ini

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,33 +2378,33 @@ ROUTER = console
23782378
;; Path for chunked uploads. Defaults to APP_DATA_PATH + `tmp/package-upload`
23792379
;CHUNKED_UPLOAD_PATH = tmp/package-upload
23802380
;;
2381-
;; Maxmimum count of package versions a single owner can have (`-1` means no limits)
2381+
;; Maximum count of package versions a single owner can have (`-1` means no limits)
23822382
;LIMIT_TOTAL_OWNER_COUNT = -1
2383-
;; Maxmimum size of packages a single owner can use (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2383+
;; Maximum size of packages a single owner can use (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
23842384
;LIMIT_TOTAL_OWNER_SIZE = -1
2385-
;; Maxmimum size of a Composer upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2385+
;; Maximum size of a Composer upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
23862386
;LIMIT_SIZE_COMPOSER = -1
2387-
;; Maxmimum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2387+
;; Maximum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
23882388
;LIMIT_SIZE_CONAN = -1
2389-
;; Maxmimum size of a Container upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2389+
;; Maximum size of a Container upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
23902390
;LIMIT_SIZE_CONTAINER = -1
2391-
;; Maxmimum size of a Generic upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2391+
;; Maximum size of a Generic upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
23922392
;LIMIT_SIZE_GENERIC = -1
2393-
;; Maxmimum size of a Helm upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2393+
;; Maximum size of a Helm upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
23942394
;LIMIT_SIZE_HELM = -1
2395-
;; Maxmimum size of a Maven upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2395+
;; Maximum size of a Maven upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
23962396
;LIMIT_SIZE_MAVEN = -1
2397-
;; Maxmimum size of a npm upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2397+
;; Maximum size of a npm upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
23982398
;LIMIT_SIZE_NPM = -1
2399-
;; Maxmimum size of a NuGet upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2399+
;; Maximum size of a NuGet upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24002400
;LIMIT_SIZE_NUGET = -1
2401-
;; Maxmimum size of a Pub upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2401+
;; Maximum size of a Pub upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24022402
;LIMIT_SIZE_PUB = -1
2403-
;; Maxmimum size of a PyPI upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2403+
;; Maximum size of a PyPI upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24042404
;LIMIT_SIZE_PYPI = -1
2405-
;; Maxmimum size of a RubyGems upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2405+
;; Maximum size of a RubyGems upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24062406
;LIMIT_SIZE_RUBYGEMS = -1
2407-
;; Maxmimum size of a Vagrant upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
2407+
;; Maximum size of a Vagrant upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
24082408
;LIMIT_SIZE_VAGRANT = -1
24092409

24102410
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ params:
2323
goVersion: 1.19
2424
minNodeVersion: 14
2525
search: nav
26+
repo: "https://github.com/go-gitea/gitea"
27+
docContentPath: "docs/content"
2628

2729
outputs:
2830
home:

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,20 +1179,20 @@ Task queue configuration has been moved to `queue.task`. However, the below conf
11791179

11801180
- `ENABLED`: **true**: Enable/Disable package registry capabilities
11811181
- `CHUNKED_UPLOAD_PATH`: **tmp/package-upload**: Path for chunked uploads. Defaults to `APP_DATA_PATH` + `tmp/package-upload`
1182-
- `LIMIT_TOTAL_OWNER_COUNT`: **-1**: Maxmimum count of package versions a single owner can have (`-1` means no limits)
1183-
- `LIMIT_TOTAL_OWNER_SIZE`: **-1**: Maxmimum size of packages a single owner can use (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1184-
- `LIMIT_SIZE_COMPOSER`: **-1**: Maxmimum size of a Composer upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1185-
- `LIMIT_SIZE_CONAN`: **-1**: Maxmimum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1186-
- `LIMIT_SIZE_CONTAINER`: **-1**: Maxmimum size of a Container upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1187-
- `LIMIT_SIZE_GENERIC`: **-1**: Maxmimum size of a Generic upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1188-
- `LIMIT_SIZE_HELM`: **-1**: Maxmimum size of a Helm upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1189-
- `LIMIT_SIZE_MAVEN`: **-1**: Maxmimum size of a Maven upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1190-
- `LIMIT_SIZE_NPM`: **-1**: Maxmimum size of a npm upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1191-
- `LIMIT_SIZE_NUGET`: **-1**: Maxmimum size of a NuGet upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1192-
- `LIMIT_SIZE_PUB`: **-1**: Maxmimum size of a Pub upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1193-
- `LIMIT_SIZE_PYPI`: **-1**: Maxmimum size of a PyPI upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1194-
- `LIMIT_SIZE_RUBYGEMS`: **-1**: Maxmimum size of a RubyGems upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1195-
- `LIMIT_SIZE_VAGRANT`: **-1**: Maxmimum size of a Vagrant upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1182+
- `LIMIT_TOTAL_OWNER_COUNT`: **-1**: Maximum count of package versions a single owner can have (`-1` means no limits)
1183+
- `LIMIT_TOTAL_OWNER_SIZE`: **-1**: Maximum size of packages a single owner can use (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1184+
- `LIMIT_SIZE_COMPOSER`: **-1**: Maximum size of a Composer upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1185+
- `LIMIT_SIZE_CONAN`: **-1**: Maximum size of a Conan upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1186+
- `LIMIT_SIZE_CONTAINER`: **-1**: Maximum size of a Container upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1187+
- `LIMIT_SIZE_GENERIC`: **-1**: Maximum size of a Generic upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1188+
- `LIMIT_SIZE_HELM`: **-1**: Maximum size of a Helm upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1189+
- `LIMIT_SIZE_MAVEN`: **-1**: Maximum size of a Maven upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1190+
- `LIMIT_SIZE_NPM`: **-1**: Maximum size of a npm upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1191+
- `LIMIT_SIZE_NUGET`: **-1**: Maximum size of a NuGet upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1192+
- `LIMIT_SIZE_PUB`: **-1**: Maximum size of a Pub upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1193+
- `LIMIT_SIZE_PYPI`: **-1**: Maximum size of a PyPI upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1194+
- `LIMIT_SIZE_RUBYGEMS`: **-1**: Maximum size of a RubyGems upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
1195+
- `LIMIT_SIZE_VAGRANT`: **-1**: Maximum size of a Vagrant upload (`-1` means no limits, format `1000`, `1 MB`, `1 GiB`)
11961196

11971197
## Mirror (`mirror`)
11981198

docs/content/doc/packages/overview.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The following package managers are currently supported:
3232
| [Generic]({{< relref "doc/packages/generic.en-us.md" >}}) | - | any HTTP client |
3333
| [Helm]({{< relref "doc/packages/helm.en-us.md" >}}) | - | any HTTP client, `cm-push` |
3434
| [Maven]({{< relref "doc/packages/maven.en-us.md" >}}) | Java | `mvn`, `gradle` |
35-
| [npm]({{< relref "doc/packages/npm.en-us.md" >}}) | JavaScript | `npm`, `yarn` |
35+
| [npm]({{< relref "doc/packages/npm.en-us.md" >}}) | JavaScript | `npm`, `yarn`, `pnpm` |
3636
| [NuGet]({{< relref "doc/packages/nuget.en-us.md" >}}) | .NET | `nuget` |
3737
| [Pub]({{< relref "doc/packages/pub.en-us.md" >}}) | Dart | `dart`, `flutter` |
3838
| [PyPI]({{< relref "doc/packages/pypi.en-us.md" >}}) | Python | `pip`, `twine` |

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module code.gitea.io/gitea
33
go 1.18
44

55
require (
6-
code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b
6+
code.gitea.io/gitea-vet v0.2.2
77
code.gitea.io/sdk/gitea v0.15.1
88
codeberg.org/gusted/mcaptcha v0.0.0-20220723083913-4f3072e1d570
99
gitea.com/go-chi/binding v0.0.0-20221013104517-b29891619681
@@ -15,7 +15,7 @@ require (
1515
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121
1616
github.com/NYTimes/gziphandler v1.1.1
1717
github.com/PuerkitoBio/goquery v1.8.0
18-
github.com/alecthomas/chroma/v2 v2.3.0
18+
github.com/alecthomas/chroma/v2 v2.4.0
1919
github.com/blevesearch/bleve/v2 v2.3.4
2020
github.com/buildkite/terminal-to-html/v3 v3.7.0
2121
github.com/caddyserver/certmagic v0.17.2

go.sum

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
6565
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
6666
cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y=
6767
code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
68-
code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b h1:uv9a8eGSdQ8Dr4HyUcuHFfDsk/QuwO+wf+Y99RYdxY0=
69-
code.gitea.io/gitea-vet v0.2.2-0.20220122151748-48ebc902541b/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
68+
code.gitea.io/gitea-vet v0.2.2 h1:TEOV/Glf38iGmKzKP0EB++Z5OSL4zGg3RrAvlwaMuvk=
69+
code.gitea.io/gitea-vet v0.2.2/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFjGGfE=
7070
code.gitea.io/sdk/gitea v0.11.3/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
7171
code.gitea.io/sdk/gitea v0.15.1 h1:WJreC7YYuxbn0UDaPuWIe/mtiNKTvLN8MLkaw71yx/M=
7272
code.gitea.io/sdk/gitea v0.15.1/go.mod h1:klY2LVI3s3NChzIk/MzMn7G1FHrfU7qd63iSMVoHRBA=
@@ -160,9 +160,10 @@ github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ
160160
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
161161
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
162162
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
163+
github.com/alecthomas/assert/v2 v2.2.0 h1:f6L/b7KE2bfA+9O4FL3CM/xJccDEwPVYd5fALBiuwvw=
163164
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
164-
github.com/alecthomas/chroma/v2 v2.3.0 h1:83xfxrnjv8eK+Cf8qZDzNo3PPF9IbTWHs7z28GY6D0U=
165-
github.com/alecthomas/chroma/v2 v2.3.0/go.mod h1:mZxeWZlxP2Dy+/8cBob2PYd8O2DwNAzave5AY7A2eQw=
165+
github.com/alecthomas/chroma/v2 v2.4.0 h1:Loe2ZjT5x3q1bcWwemqyqEi8p11/IV/ncFCeLYDpWC4=
166+
github.com/alecthomas/chroma/v2 v2.4.0/go.mod h1:6kHzqF5O6FUSJzBXW7fXELjb+e+7OXW4UpoPqMO7IBQ=
166167
github.com/alecthomas/kingpin v2.2.6+incompatible/go.mod h1:59OFYbFVLKQKq+mqrL6Rw5bR0c3ACQaawgXx0QYndlE=
167168
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
168169
github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE=
@@ -830,6 +831,7 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
830831
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
831832
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
832833
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
834+
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
833835
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
834836
github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo=
835837
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=

models/activities/action.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ func (a *Action) GetOpType() ActionType {
114114
}
115115

116116
// LoadActUser loads a.ActUser
117-
func (a *Action) LoadActUser() {
117+
func (a *Action) LoadActUser(ctx context.Context) {
118118
if a.ActUser != nil {
119119
return
120120
}
121121
var err error
122-
a.ActUser, err = user_model.GetUserByID(a.ActUserID)
122+
a.ActUser, err = user_model.GetUserByID(ctx, a.ActUserID)
123123
if err == nil {
124124
return
125125
} else if user_model.IsErrUserNotExist(err) {
@@ -129,26 +129,26 @@ func (a *Action) LoadActUser() {
129129
}
130130
}
131131

132-
func (a *Action) loadRepo() {
132+
func (a *Action) loadRepo(ctx context.Context) {
133133
if a.Repo != nil {
134134
return
135135
}
136136
var err error
137-
a.Repo, err = repo_model.GetRepositoryByID(a.RepoID)
137+
a.Repo, err = repo_model.GetRepositoryByID(ctx, a.RepoID)
138138
if err != nil {
139139
log.Error("repo_model.GetRepositoryByID(%d): %v", a.RepoID, err)
140140
}
141141
}
142142

143143
// GetActFullName gets the action's user full name.
144144
func (a *Action) GetActFullName() string {
145-
a.LoadActUser()
145+
a.LoadActUser(db.DefaultContext)
146146
return a.ActUser.FullName
147147
}
148148

149149
// GetActUserName gets the action's user name.
150150
func (a *Action) GetActUserName() string {
151-
a.LoadActUser()
151+
a.LoadActUser(db.DefaultContext)
152152
return a.ActUser.Name
153153
}
154154

@@ -179,7 +179,7 @@ func (a *Action) GetDisplayNameTitle() string {
179179

180180
// GetRepoUserName returns the name of the action repository owner.
181181
func (a *Action) GetRepoUserName() string {
182-
a.loadRepo()
182+
a.loadRepo(db.DefaultContext)
183183
return a.Repo.OwnerName
184184
}
185185

@@ -191,7 +191,7 @@ func (a *Action) ShortRepoUserName() string {
191191

192192
// GetRepoName returns the name of the action repository.
193193
func (a *Action) GetRepoName() string {
194-
a.loadRepo()
194+
a.loadRepo(db.DefaultContext)
195195
return a.Repo.Name
196196
}
197197

@@ -379,7 +379,7 @@ func activityQueryCondition(opts GetFeedsOptions) (builder.Cond, error) {
379379
cond := builder.NewCond()
380380

381381
if opts.RequestedTeam != nil && opts.RequestedUser == nil {
382-
org, err := user_model.GetUserByID(opts.RequestedTeam.OrgID)
382+
org, err := user_model.GetUserByID(db.DefaultContext, opts.RequestedTeam.OrgID)
383383
if err != nil {
384384
return nil, err
385385
}
@@ -489,7 +489,7 @@ func NotifyWatchers(ctx context.Context, actions ...*Action) error {
489489
}
490490

491491
if repoChanged {
492-
act.loadRepo()
492+
act.loadRepo(ctx)
493493
repo = act.Repo
494494

495495
// check repo owner exist.
@@ -514,7 +514,7 @@ func NotifyWatchers(ctx context.Context, actions ...*Action) error {
514514
permIssue = make([]bool, len(watchers))
515515
permPR = make([]bool, len(watchers))
516516
for i, watcher := range watchers {
517-
user, err := user_model.GetUserByIDCtx(ctx, watcher.UserID)
517+
user, err := user_model.GetUserByID(ctx, watcher.UserID)
518518
if err != nil {
519519
permCode[i] = false
520520
permIssue[i] = false

models/activities/action_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (actions ActionList) loadRepoOwner(ctx context.Context, userMap map[int64]*
8181
}
8282
repoOwner, ok := userMap[action.Repo.OwnerID]
8383
if !ok {
84-
repoOwner, err = user_model.GetUserByIDCtx(ctx, action.Repo.OwnerID)
84+
repoOwner, err = user_model.GetUserByID(ctx, action.Repo.OwnerID)
8585
if err != nil {
8686
if user_model.IsErrUserNotExist(err) {
8787
continue

models/activities/notification.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func createOrUpdateIssueNotifications(ctx context.Context, issueID, commentID, n
245245
// notify
246246
for userID := range toNotify {
247247
issue.Repo.Units = nil
248-
user, err := user_model.GetUserByIDCtx(ctx, userID)
248+
user, err := user_model.GetUserByID(ctx, userID)
249249
if err != nil {
250250
if user_model.IsErrUserNotExist(err) {
251251
continue
@@ -388,7 +388,7 @@ func (n *Notification) LoadAttributes(ctx context.Context) (err error) {
388388

389389
func (n *Notification) loadRepo(ctx context.Context) (err error) {
390390
if n.Repository == nil {
391-
n.Repository, err = repo_model.GetRepositoryByIDCtx(ctx, n.RepoID)
391+
n.Repository, err = repo_model.GetRepositoryByID(ctx, n.RepoID)
392392
if err != nil {
393393
return fmt.Errorf("getRepositoryByID [%d]: %w", n.RepoID, err)
394394
}
@@ -425,7 +425,7 @@ func (n *Notification) loadComment(ctx context.Context) (err error) {
425425

426426
func (n *Notification) loadUser(ctx context.Context) (err error) {
427427
if n.User == nil {
428-
n.User, err = user_model.GetUserByIDCtx(ctx, n.UserID)
428+
n.User, err = user_model.GetUserByID(ctx, n.UserID)
429429
if err != nil {
430430
return fmt.Errorf("getUserByID [%d]: %w", n.UserID, err)
431431
}

models/asymkey/gpg_key_commit_verification.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ func hashAndVerifyForKeyID(sig *packet.Signature, payload string, committer *use
426426
Email: email,
427427
}
428428
if key.OwnerID != 0 {
429-
owner, err := user_model.GetUserByID(key.OwnerID)
429+
owner, err := user_model.GetUserByID(db.DefaultContext, key.OwnerID)
430430
if err == nil {
431431
signer = owner
432432
} else if !user_model.IsErrUserNotExist(err) {

models/db/index.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import (
77
"context"
88
"errors"
99
"fmt"
10+
"strconv"
11+
12+
"code.gitea.io/gitea/modules/setting"
1013
)
1114

1215
// ResourceIndex represents a resource index which could be used as issue/release and others
@@ -23,11 +26,6 @@ var (
2326
ErrGetResourceIndexFailed = errors.New("get resource index failed")
2427
)
2528

26-
const (
27-
// MaxDupIndexAttempts max retry times to create index
28-
MaxDupIndexAttempts = 3
29-
)
30-
3129
// SyncMaxResourceIndex sync the max index with the resource
3230
func SyncMaxResourceIndex(ctx context.Context, tableName string, groupID, maxIndex int64) (err error) {
3331
e := GetEngine(ctx)
@@ -60,8 +58,25 @@ func SyncMaxResourceIndex(ctx context.Context, tableName string, groupID, maxInd
6058
return nil
6159
}
6260

61+
func postgresGetNextResourceIndex(ctx context.Context, tableName string, groupID int64) (int64, error) {
62+
res, err := GetEngine(ctx).Query(fmt.Sprintf("INSERT INTO %s (group_id, max_index) "+
63+
"VALUES (?,1) ON CONFLICT (group_id) DO UPDATE SET max_index = %s.max_index+1 RETURNING max_index",
64+
tableName, tableName), groupID)
65+
if err != nil {
66+
return 0, err
67+
}
68+
if len(res) == 0 {
69+
return 0, ErrGetResourceIndexFailed
70+
}
71+
return strconv.ParseInt(string(res[0]["max_index"]), 10, 64)
72+
}
73+
6374
// GetNextResourceIndex generates a resource index, it must run in the same transaction where the resource is created
6475
func GetNextResourceIndex(ctx context.Context, tableName string, groupID int64) (int64, error) {
76+
if setting.Database.UsePostgreSQL {
77+
return postgresGetNextResourceIndex(ctx, tableName, groupID)
78+
}
79+
6580
e := GetEngine(ctx)
6681

6782
// try to update the max_index to next value, and acquire the write-lock for the record

0 commit comments

Comments
 (0)