Skip to content

Commit 585e34b

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Fix missed merge commit sha and time when migrating from codecommit (go-gitea#34645) [skip ci] Updated translations via Crowdin Fix GetUsersByEmails (go-gitea#34643) Add `--color-logo` for text that should match logo color (go-gitea#34639) Update JS deps, regenerate SVGs (go-gitea#34640) Misc CSS fixes (go-gitea#34638) Validate hex colors when creating/editing labels (go-gitea#34623) add codecommit to supported services in api docs (go-gitea#34626) add openssh-keygen to rootless image (go-gitea#34625) Small fix in Pull Requests page (go-gitea#34612) bump to alpine 3.22 (go-gitea#34613) Fix notification count positioning for variable-width elements (go-gitea#34597) Fix margin issue in markup paragraph rendering (go-gitea#34599) # Conflicts: # templates/home.tmpl
2 parents 8d55fae + 1fe652c commit 585e34b

Some content is hidden

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

42 files changed

+1382
-899
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.24-alpine3.21 AS build-env
2+
FROM docker.io/library/golang:1.24-alpine3.22 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY=${GOPROXY:-direct}
@@ -41,7 +41,7 @@ RUN chmod 755 /tmp/local/usr/bin/entrypoint \
4141
/go/src/code.gitea.io/gitea/environment-to-ini
4242
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4343

44-
FROM docker.io/library/alpine:3.21
44+
FROM docker.io/library/alpine:3.22
4545
LABEL maintainer="[email protected]"
4646

4747
EXPOSE 22 3000

Dockerfile.rootless

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.24-alpine3.21 AS build-env
2+
FROM docker.io/library/golang:1.24-alpine3.22 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY=${GOPROXY:-direct}
@@ -39,7 +39,7 @@ RUN chmod 755 /tmp/local/usr/local/bin/docker-entrypoint.sh \
3939
/go/src/code.gitea.io/gitea/environment-to-ini
4040
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4141

42-
FROM docker.io/library/alpine:3.21
42+
FROM docker.io/library/alpine:3.22
4343
LABEL maintainer="[email protected]"
4444

4545
EXPOSE 2222 3000
@@ -52,6 +52,7 @@ RUN apk --no-cache add \
5252
git \
5353
curl \
5454
gnupg \
55+
openssh-keygen \
5556
&& rm -rf /var/cache/apk/*
5657

5758
RUN addgroup \

models/fixtures/email_address.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
-
8282
id: 11
8383
uid: 4
84-
84+
8585
lower_email: [email protected]
8686
is_activated: true
8787
is_primary: true

models/user/user.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,8 @@ func ValidateCommitsWithEmails(ctx context.Context, oldCommits []*git.Commit) ([
11511151
}
11521152

11531153
for _, c := range oldCommits {
1154-
user, ok := emailUserMap[c.Author.Email]
1155-
if !ok {
1154+
user := emailUserMap.GetByEmail(c.Author.Email) // FIXME: why ValidateCommitsWithEmails uses "Author", but ParseCommitsWithSignature uses "Committer"?
1155+
if user == nil {
11561156
user = &User{
11571157
Name: c.Author.Name,
11581158
Email: c.Author.Email,
@@ -1166,7 +1166,15 @@ func ValidateCommitsWithEmails(ctx context.Context, oldCommits []*git.Commit) ([
11661166
return newCommits, nil
11671167
}
11681168

1169-
func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, error) {
1169+
type EmailUserMap struct {
1170+
m map[string]*User
1171+
}
1172+
1173+
func (eum *EmailUserMap) GetByEmail(email string) *User {
1174+
return eum.m[strings.ToLower(email)]
1175+
}
1176+
1177+
func GetUsersByEmails(ctx context.Context, emails []string) (*EmailUserMap, error) {
11701178
if len(emails) == 0 {
11711179
return nil, nil
11721180
}
@@ -1176,7 +1184,7 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
11761184
for _, email := range emails {
11771185
if strings.HasSuffix(email, "@"+setting.Service.NoReplyAddress) {
11781186
username := strings.TrimSuffix(email, "@"+setting.Service.NoReplyAddress)
1179-
needCheckUserNames.Add(username)
1187+
needCheckUserNames.Add(strings.ToLower(username))
11801188
} else {
11811189
needCheckEmails.Add(strings.ToLower(email))
11821190
}
@@ -1203,8 +1211,7 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
12031211
for _, email := range emailAddresses {
12041212
user := users[email.UID]
12051213
if user != nil {
1206-
results[user.Email] = user
1207-
results[user.GetPlaceholderEmail()] = user
1214+
results[email.LowerEmail] = user
12081215
}
12091216
}
12101217
}
@@ -1214,10 +1221,9 @@ func GetUsersByEmails(ctx context.Context, emails []string) (map[string]*User, e
12141221
return nil, err
12151222
}
12161223
for _, user := range users {
1217-
results[user.Email] = user
1218-
results[user.GetPlaceholderEmail()] = user
1224+
results[strings.ToLower(user.GetPlaceholderEmail())] = user
12191225
}
1220-
return results, nil
1226+
return &EmailUserMap{results}, nil
12211227
}
12221228

12231229
// GetUserByEmail returns the user object by given e-mail if exists.

models/user/user_test.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,33 @@ func TestUserEmails(t *testing.T) {
5858
assert.ElementsMatch(t, []string{"[email protected]"}, user_model.GetUserEmailsByNames(db.DefaultContext, []string{"user8", "org7"}))
5959
})
6060
t.Run("GetUsersByEmails", func(t *testing.T) {
61-
m, err := user_model.GetUsersByEmails(db.DefaultContext, []string{"[email protected]", "user2@" + setting.Service.NoReplyAddress})
62-
require.NoError(t, err)
63-
require.Len(t, m, 4)
64-
assert.EqualValues(t, 1, m["[email protected]"].ID)
65-
assert.EqualValues(t, 1, m["user1@"+setting.Service.NoReplyAddress].ID)
66-
assert.EqualValues(t, 2, m["[email protected]"].ID)
67-
assert.EqualValues(t, 2, m["user2@"+setting.Service.NoReplyAddress].ID)
61+
defer test.MockVariableValue(&setting.Service.NoReplyAddress, "NoReply.gitea.internal")()
62+
testGetUserByEmail := func(t *testing.T, email string, uid int64) {
63+
m, err := user_model.GetUsersByEmails(db.DefaultContext, []string{email})
64+
require.NoError(t, err)
65+
user := m.GetByEmail(email)
66+
if uid == 0 {
67+
require.Nil(t, user)
68+
return
69+
}
70+
require.NotNil(t, user)
71+
assert.Equal(t, uid, user.ID)
72+
}
73+
cases := []struct {
74+
Email string
75+
UID int64
76+
}{
77+
78+
79+
{"USER2@" + setting.Service.NoReplyAddress, 2},
80+
81+
{"no-such", 0},
82+
}
83+
for _, c := range cases {
84+
t.Run(c.Email, func(t *testing.T) {
85+
testGetUserByEmail(t, c.Email, c.UID)
86+
})
87+
}
6888
})
6989
}
7090

modules/label/label.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
"fmt"
88
"regexp"
99
"strings"
10-
)
10+
"sync"
1111

12-
// colorPattern is a regexp which can validate label color
13-
var colorPattern = regexp.MustCompile("^#?(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})$")
12+
"code.gitea.io/gitea/modules/util"
13+
)
1414

1515
// Label represents label information loaded from template
1616
type Label struct {
@@ -21,6 +21,10 @@ type Label struct {
2121
ExclusiveOrder int `yaml:"exclusive_order,omitempty"`
2222
}
2323

24+
var colorPattern = sync.OnceValue(func() *regexp.Regexp {
25+
return regexp.MustCompile(`^#([\da-fA-F]{3}|[\da-fA-F]{6})$`)
26+
})
27+
2428
// NormalizeColor normalizes a color string to a 6-character hex code
2529
func NormalizeColor(color string) (string, error) {
2630
// normalize case
@@ -31,8 +35,8 @@ func NormalizeColor(color string) (string, error) {
3135
color = "#" + color
3236
}
3337

34-
if !colorPattern.MatchString(color) {
35-
return "", fmt.Errorf("bad color code: %s", color)
38+
if !colorPattern().MatchString(color) {
39+
return "", util.NewInvalidArgumentErrorf("invalid color: %s", color)
3640
}
3741

3842
// convert 3-character shorthand into 6-character version

modules/structs/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ type MigrateRepoOptions struct {
359359
// required: true
360360
RepoName string `json:"repo_name" binding:"Required;AlphaDashDot;MaxSize(100)"`
361361

362-
// enum: git,github,gitea,gitlab,gogs,onedev,gitbucket,codebase
362+
// enum: git,github,gitea,gitlab,gogs,onedev,gitbucket,codebase,codecommit
363363
Service string `json:"service"`
364364
AuthUsername string `json:"auth_username"`
365365
AuthPassword string `json:"auth_password"`

modules/test/utils.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
// RedirectURL returns the redirect URL of a http response.
1919
// It also works for JSONRedirect: `{"redirect": "..."}`
20+
// FIXME: it should separate the logic of checking from header and JSON body
2021
func RedirectURL(resp http.ResponseWriter) string {
2122
loc := resp.Header().Get("Location")
2223
if loc != "" {
@@ -34,6 +35,15 @@ func RedirectURL(resp http.ResponseWriter) string {
3435
return ""
3536
}
3637

38+
func ParseJSONError(buf []byte) (ret struct {
39+
ErrorMessage string `json:"errorMessage"`
40+
RenderFormat string `json:"renderFormat"`
41+
},
42+
) {
43+
_ = json.Unmarshal(buf, &ret)
44+
return ret
45+
}
46+
3747
func IsNormalPageCompleted(s string) bool {
3848
return strings.Contains(s, `<footer class="page-footer"`) && strings.Contains(s, `</html>`)
3949
}

options/fileicon/material-icon-rules.json

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

options/fileicon/material-icon-svgs.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

options/locale/locale_en-US.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,6 @@ commitstatus.success = Success
14331433
ext_issues = Access to External Issues
14341434
ext_issues.desc = Link to an external issue tracker.
14351435
1436-
projects = Projects
14371436
projects.desc = Manage issues and pulls in projects.
14381437
projects.description = Description (optional)
14391438
projects.description_placeholder = Description
@@ -1561,6 +1560,7 @@ issues.filter_user_placeholder = Search users
15611560
issues.filter_user_no_select = All users
15621561
issues.filter_type = Type
15631562
issues.filter_type.all_issues = All issues
1563+
issues.filter_type.all_pull_requests = All pull requests
15641564
issues.filter_type.assigned_to_you = Assigned to you
15651565
issues.filter_type.created_by_you = Created by you
15661566
issues.filter_type.mentioning_you = Mentioning you
@@ -1652,6 +1652,7 @@ issues.save = Save
16521652
issues.label_title = Name
16531653
issues.label_description = Description
16541654
issues.label_color = Color
1655+
issues.label_color_invalid = Invalid color
16551656
issues.label_exclusive = Exclusive
16561657
issues.label_archive = Archive Label
16571658
issues.label_archived_filter = Show archived labels

options/locale/locale_fr-FR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,7 @@ issues.filter_user_placeholder=Rechercher des utilisateurs
15601560
issues.filter_user_no_select=Tous les utilisateurs
15611561
issues.filter_type=Type
15621562
issues.filter_type.all_issues=Tous les tickets
1563+
issues.filter_type.all_pull_requests=Toutes les demandes d’ajout
15631564
issues.filter_type.assigned_to_you=Qui vous sont assignés
15641565
issues.filter_type.created_by_you=Créés par vous
15651566
issues.filter_type.mentioning_you=Vous mentionnant

0 commit comments

Comments
 (0)