Skip to content

Commit 1688a0c

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: (23 commits) Remove jQuery from SSH key form parser (go-gitea#29193) Refactor request function (go-gitea#29187) Docker Tag Information in Docs (go-gitea#29047) Fix gitea-action user avatar broken on edited menu (go-gitea#29190) Disable parallel Make execution (go-gitea#29186) Auto-update the system status in admin dashboard (go-gitea#29163) Avoid vue warning in dev mode (go-gitea#29188) Update JS and PY dependencies (go-gitea#29184) [skip ci] Updated translations via Crowdin Implement contributors graph (go-gitea#27882) Add support for action artifact serve direct (go-gitea#29120) Advertise WebAuthn support (go-gitea#29176) Tweak repo header (go-gitea#29134) Change webhook-type in create-view (go-gitea#29114) Remove jQuery from the comment task list (go-gitea#29170) Fix can not select team reviewers when reviewers is empty (go-gitea#29174) move sign in labels to be above inputs (go-gitea#28753) Refactor locale&string&template related code (go-gitea#29165) Extract linguist code to method (go-gitea#29168) bump to use go 1.22 (go-gitea#29119) ...
2 parents 82aedae + 236e121 commit 1688a0c

File tree

145 files changed

+2903
-1216
lines changed

Some content is hidden

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

145 files changed

+2903
-1216
lines changed

Diff for: .devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Gitea DevContainer",
3-
"image": "mcr.microsoft.com/devcontainers/go:1.21-bullseye",
3+
"image": "mcr.microsoft.com/devcontainers/go:1.22-bullseye",
44
"features": {
55
// installs nodejs into container
66
"ghcr.io/devcontainers/features/node:1": {

Diff for: Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.21-alpine3.19 AS build-env
2+
FROM docker.io/library/golang:1.22-alpine3.19 AS build-env
33

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

Diff for: Dockerfile.rootless

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.21-alpine3.19 AS build-env
2+
FROM docker.io/library/golang:1.22-alpine3.19 AS build-env
33

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

Diff for: Makefile

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ SHASUM ?= shasum -a 256
2323
HAS_GO := $(shell hash $(GO) > /dev/null 2>&1 && echo yes)
2424
COMMA := ,
2525

26-
XGO_VERSION := go-1.21.x
26+
XGO_VERSION := go-1.22.x
2727

2828
AIR_PACKAGE ?= github.com/cosmtrek/[email protected]
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.1
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
@@ -988,3 +988,8 @@ docker:
988988

989989
# This endif closes the if at the top of the file
990990
endif
991+
992+
# Disable parallel execution because it would break some targets that don't
993+
# specify exact dependencies like 'backend' which does currently not depend
994+
# on 'frontend' to enable Node.js-less builds from source tarballs.
995+
.NOTPARALLEL:

Diff for: README.md

-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ The `build` target is split into two sub-targets:
8989

9090
Internet connectivity is required to download the go and npm modules. When building from the official source tarballs which include pre-built frontend files, the `frontend` target will not be triggered, making it possible to build without Node.js.
9191

92-
Parallelism (`make -j <num>`) is not supported.
93-
9492
More info: https://docs.gitea.com/installation/install-from-source
9593

9694
## Using

Diff for: docs/content/usage/packages/container.en-us.md

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ Images must follow this naming convention:
3939

4040
`{registry}/{owner}/{image}`
4141

42+
When building your docker image, using the naming convention above, this looks like:
43+
44+
```shell
45+
# build an image with tag
46+
docker build -t {registry}/{owner}/{image}:{tag} .
47+
# name an existing image with tag
48+
docker tag {some-existing-image}:{tag} {registry}/{owner}/{image}:{tag}
49+
```
50+
51+
where your registry is the domain of your gitea instance (e.g. gitea.example.com).
4252
For example, these are all valid image names for the owner `testuser`:
4353

4454
`gitea.example.com/testuser/myimage`

Diff for: models/actions/runner.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (r *ActionRunner) StatusName() string {
9797
}
9898

9999
func (r *ActionRunner) StatusLocaleName(lang translation.Locale) string {
100-
return lang.Tr("actions.runners.status." + r.StatusName())
100+
return lang.TrString("actions.runners.status." + r.StatusName())
101101
}
102102

103103
func (r *ActionRunner) IsOnline() bool {

Diff for: models/actions/status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (s Status) String() string {
4141

4242
// LocaleString returns the locale string name of the Status
4343
func (s Status) LocaleString(lang translation.Locale) string {
44-
return lang.Tr("actions.status." + s.String())
44+
return lang.TrString("actions.status." + s.String())
4545
}
4646

4747
// IsDone returns whether the Status is final

Diff for: models/git/commit_status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (status *CommitStatus) APIURL(ctx context.Context) string {
194194

195195
// LocaleString returns the locale string name of the Status
196196
func (status *CommitStatus) LocaleString(lang translation.Locale) string {
197-
return lang.Tr("repo.commitstatus." + status.State.String())
197+
return lang.TrString("repo.commitstatus." + status.State.String())
198198
}
199199

200200
// CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc

Diff for: models/issues/comment.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ const (
210210

211211
// LocaleString returns the locale string name of the role
212212
func (r RoleInRepo) LocaleString(lang translation.Locale) string {
213-
return lang.Tr("repo.issues.role." + string(r))
213+
return lang.TrString("repo.issues.role." + string(r))
214214
}
215215

216216
// LocaleHelper returns the locale tooltip of the role
217217
func (r RoleInRepo) LocaleHelper(lang translation.Locale) string {
218-
return lang.Tr("repo.issues.role." + string(r) + "_helper")
218+
return lang.TrString("repo.issues.role." + string(r) + "_helper")
219219
}
220220

221221
// Comment represents a comment in commit and issue page.

Diff for: models/issues/comment_list.go

+4
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ func (comments CommentList) loadAssignees(ctx context.Context) error {
225225

226226
for _, comment := range comments {
227227
comment.Assignee = assignees[comment.AssigneeID]
228+
if comment.Assignee == nil {
229+
comment.AssigneeID = user_model.GhostUserID
230+
comment.Assignee = user_model.NewGhostUser()
231+
}
228232
}
229233
return nil
230234
}

Diff for: models/issues/content_history.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ func FetchIssueContentHistoryList(dbCtx context.Context, issueID, commentID int6
161161
}
162162

163163
for _, item := range res {
164-
item.UserAvatarLink = avatars.GenerateUserAvatarFastLink(item.UserName, 0)
164+
if item.UserID > 0 {
165+
item.UserAvatarLink = avatars.GenerateUserAvatarFastLink(item.UserName, 0)
166+
} else {
167+
item.UserAvatarLink = avatars.DefaultAvatarLink()
168+
}
165169
}
166170
return res, nil
167171
}

Diff for: models/issues/issue_xref.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ func neuterCrossReferences(ctx context.Context, issueID, commentID int64) error
4646
for i, c := range active {
4747
ids[i] = c.ID
4848
}
49-
return neuterCrossReferencesIds(ctx, ids)
49+
return neuterCrossReferencesIDs(ctx, ids)
5050
}
5151

52-
func neuterCrossReferencesIds(ctx context.Context, ids []int64) error {
52+
func neuterCrossReferencesIDs(ctx context.Context, ids []int64) error {
5353
_, err := db.GetEngine(ctx).In("id", ids).Cols("`ref_action`").Update(&Comment{RefAction: references.XRefActionNeutered})
5454
return err
5555
}
@@ -100,7 +100,7 @@ func (issue *Issue) createCrossReferences(stdCtx context.Context, ctx *crossRefe
100100
}
101101
}
102102
if len(ids) > 0 {
103-
if err = neuterCrossReferencesIds(stdCtx, ids); err != nil {
103+
if err = neuterCrossReferencesIDs(stdCtx, ids); err != nil {
104104
return err
105105
}
106106
}

Diff for: models/issues/review.go

+8
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ func (r *Review) LoadReviewer(ctx context.Context) (err error) {
159159
return err
160160
}
161161
r.Reviewer, err = user_model.GetPossibleUserByID(ctx, r.ReviewerID)
162+
if err != nil {
163+
if !user_model.IsErrUserNotExist(err) {
164+
return fmt.Errorf("GetPossibleUserByID [%d]: %w", r.ReviewerID, err)
165+
}
166+
r.ReviewerID = user_model.GhostUserID
167+
r.Reviewer = user_model.NewGhostUser()
168+
return nil
169+
}
162170
return err
163171
}
164172

Diff for: models/issues/review_list.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ type ReviewList []*Review
1818

1919
// LoadReviewers loads reviewers
2020
func (reviews ReviewList) LoadReviewers(ctx context.Context) error {
21-
reviewerIds := make([]int64, len(reviews))
21+
reviewerIDs := make([]int64, len(reviews))
2222
for i := 0; i < len(reviews); i++ {
23-
reviewerIds[i] = reviews[i].ReviewerID
23+
reviewerIDs[i] = reviews[i].ReviewerID
2424
}
25-
reviewers, err := user_model.GetPossibleUserByIDs(ctx, reviewerIds)
25+
reviewers, err := user_model.GetPossibleUserByIDs(ctx, reviewerIDs)
2626
if err != nil {
2727
return err
2828
}
@@ -38,12 +38,12 @@ func (reviews ReviewList) LoadReviewers(ctx context.Context) error {
3838
}
3939

4040
func (reviews ReviewList) LoadIssues(ctx context.Context) error {
41-
issueIds := container.Set[int64]{}
41+
issueIDs := container.Set[int64]{}
4242
for i := 0; i < len(reviews); i++ {
43-
issueIds.Add(reviews[i].IssueID)
43+
issueIDs.Add(reviews[i].IssueID)
4444
}
4545

46-
issues, err := GetIssuesByIDs(ctx, issueIds.Values())
46+
issues, err := GetIssuesByIDs(ctx, issueIDs.Values())
4747
if err != nil {
4848
return err
4949
}

Diff for: models/organization/org.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,7 @@ func GetOrgByID(ctx context.Context, id int64) (*Organization, error) {
594594
return nil, err
595595
} else if !has {
596596
return nil, user_model.ErrUserNotExist{
597-
UID: id,
598-
Name: "",
599-
KeyID: 0,
597+
UID: id,
600598
}
601599
}
602600
return u, nil

Diff for: models/shared/types/ownertype.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ const (
1717
func (o OwnerType) LocaleString(locale translation.Locale) string {
1818
switch o {
1919
case OwnerTypeSystemGlobal:
20-
return locale.Tr("concept_system_global")
20+
return locale.TrString("concept_system_global")
2121
case OwnerTypeIndividual:
22-
return locale.Tr("concept_user_individual")
22+
return locale.TrString("concept_user_individual")
2323
case OwnerTypeRepository:
24-
return locale.Tr("concept_code_repository")
24+
return locale.TrString("concept_code_repository")
2525
case OwnerTypeOrganization:
26-
return locale.Tr("concept_user_organization")
26+
return locale.TrString("concept_user_organization")
2727
}
28-
return locale.Tr("unknown")
28+
return locale.TrString("unknown")
2929
}

Diff for: models/user/email_address.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,7 @@ func MakeEmailPrimary(ctx context.Context, email *EmailAddress) error {
332332
return err
333333
} else if !has {
334334
return ErrUserNotExist{
335-
UID: email.UID,
336-
Name: "",
337-
KeyID: 0,
335+
UID: email.UID,
338336
}
339337
}
340338

Diff for: models/user/error.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ func (err ErrUserAlreadyExist) Unwrap() error {
3131

3232
// ErrUserNotExist represents a "UserNotExist" kind of error.
3333
type ErrUserNotExist struct {
34-
UID int64
35-
Name string
36-
KeyID int64
34+
UID int64
35+
Name string
3736
}
3837

3938
// IsErrUserNotExist checks if an error is a ErrUserNotExist.
@@ -43,7 +42,7 @@ func IsErrUserNotExist(err error) bool {
4342
}
4443

4544
func (err ErrUserNotExist) Error() string {
46-
return fmt.Sprintf("user does not exist [uid: %d, name: %s, keyid: %d]", err.UID, err.Name, err.KeyID)
45+
return fmt.Sprintf("user does not exist [uid: %d, name: %s]", err.UID, err.Name)
4746
}
4847

4948
// Unwrap unwraps this error as a ErrNotExist error

Diff for: models/user/user.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ func GetUserByID(ctx context.Context, id int64) (*User, error) {
835835
if err != nil {
836836
return nil, err
837837
} else if !has {
838-
return nil, ErrUserNotExist{id, "", 0}
838+
return nil, ErrUserNotExist{UID: id}
839839
}
840840
return u, nil
841841
}
@@ -885,14 +885,14 @@ func GetPossibleUserByIDs(ctx context.Context, ids []int64) ([]*User, error) {
885885
// GetUserByNameCtx returns user by given name.
886886
func GetUserByName(ctx context.Context, name string) (*User, error) {
887887
if len(name) == 0 {
888-
return nil, ErrUserNotExist{0, name, 0}
888+
return nil, ErrUserNotExist{Name: name}
889889
}
890890
u := &User{LowerName: strings.ToLower(name), Type: UserTypeIndividual}
891891
has, err := db.GetEngine(ctx).Get(u)
892892
if err != nil {
893893
return nil, err
894894
} else if !has {
895-
return nil, ErrUserNotExist{0, name, 0}
895+
return nil, ErrUserNotExist{Name: name}
896896
}
897897
return u, nil
898898
}
@@ -1033,7 +1033,7 @@ func ValidateCommitsWithEmails(ctx context.Context, oldCommits []*git.Commit) []
10331033
// GetUserByEmail returns the user object by given e-mail if exists.
10341034
func GetUserByEmail(ctx context.Context, email string) (*User, error) {
10351035
if len(email) == 0 {
1036-
return nil, ErrUserNotExist{0, email, 0}
1036+
return nil, ErrUserNotExist{Name: email}
10371037
}
10381038

10391039
email = strings.ToLower(email)
@@ -1060,7 +1060,7 @@ func GetUserByEmail(ctx context.Context, email string) (*User, error) {
10601060
}
10611061
}
10621062

1063-
return nil, ErrUserNotExist{0, email, 0}
1063+
return nil, ErrUserNotExist{Name: email}
10641064
}
10651065

10661066
// GetUser checks if a user already exists
@@ -1071,7 +1071,7 @@ func GetUser(ctx context.Context, user *User) (bool, error) {
10711071
// GetUserByOpenID returns the user object by given OpenID if exists.
10721072
func GetUserByOpenID(ctx context.Context, uri string) (*User, error) {
10731073
if len(uri) == 0 {
1074-
return nil, ErrUserNotExist{0, uri, 0}
1074+
return nil, ErrUserNotExist{Name: uri}
10751075
}
10761076

10771077
uri, err := openid.Normalize(uri)
@@ -1091,7 +1091,7 @@ func GetUserByOpenID(ctx context.Context, uri string) (*User, error) {
10911091
return GetUserByID(ctx, oid.UID)
10921092
}
10931093

1094-
return nil, ErrUserNotExist{0, uri, 0}
1094+
return nil, ErrUserNotExist{Name: uri}
10951095
}
10961096

10971097
// GetAdminUser returns the first administrator

Diff for: modules/auth/password/password.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"crypto/rand"
1010
"errors"
11+
"html/template"
1112
"math/big"
1213
"strings"
1314
"sync"
@@ -121,15 +122,15 @@ func Generate(n int) (string, error) {
121122
}
122123

123124
// BuildComplexityError builds the error message when password complexity checks fail
124-
func BuildComplexityError(locale translation.Locale) string {
125+
func BuildComplexityError(locale translation.Locale) template.HTML {
125126
var buffer bytes.Buffer
126-
buffer.WriteString(locale.Tr("form.password_complexity"))
127+
buffer.WriteString(locale.TrString("form.password_complexity"))
127128
buffer.WriteString("<ul>")
128129
for _, c := range requiredList {
129130
buffer.WriteString("<li>")
130-
buffer.WriteString(locale.Tr(c.TrNameOne))
131+
buffer.WriteString(locale.TrString(c.TrNameOne))
131132
buffer.WriteString("</li>")
132133
}
133134
buffer.WriteString("</ul>")
134-
return buffer.String()
135+
return template.HTML(buffer.String())
135136
}

Diff for: modules/charset/escape_stream.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (e *escapeStreamer) ambiguousRune(r, c rune) error {
173173
Val: "ambiguous-code-point",
174174
}, html.Attribute{
175175
Key: "data-tooltip-content",
176-
Val: e.locale.Tr("repo.ambiguous_character", r, c),
176+
Val: e.locale.TrString("repo.ambiguous_character", r, c),
177177
}); err != nil {
178178
return err
179179
}

Diff for: modules/context/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func APIContexter() func(http.Handler) http.Handler {
245245
// NotFound handles 404s for APIContext
246246
// String will replace message, errors will be added to a slice
247247
func (ctx *APIContext) NotFound(objs ...any) {
248-
message := ctx.Tr("error.not_found")
248+
message := ctx.Locale.TrString("error.not_found")
249249
var errors []string
250250
for _, obj := range objs {
251251
// Ignore nil

Diff for: modules/context/base.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package context
66
import (
77
"context"
88
"fmt"
9+
"html/template"
910
"io"
1011
"net/http"
1112
"net/url"
@@ -286,11 +287,11 @@ func (b *Base) cleanUp() {
286287
}
287288
}
288289

289-
func (b *Base) Tr(msg string, args ...any) string {
290+
func (b *Base) Tr(msg string, args ...any) template.HTML {
290291
return b.Locale.Tr(msg, args...)
291292
}
292293

293-
func (b *Base) TrN(cnt any, key1, keyN string, args ...any) string {
294+
func (b *Base) TrN(cnt any, key1, keyN string, args ...any) template.HTML {
294295
return b.Locale.TrN(cnt, key1, keyN, args...)
295296
}
296297

0 commit comments

Comments
 (0)