Skip to content

Commit 810335f

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Run editorconfig-checker on `locale_en-US.ini` (go-gitea#29608) bump protobuf module (go-gitea#29617) Add ac claim for old docker/build-push-action@v3 / current buildx gha cache (go-gitea#29584) Skip email domain check when admins edit user emails (go-gitea#29609) Improve natural sort (go-gitea#29611) Add empty repo check in `DetectAndHandleSchedules` (go-gitea#29606) Fix contributor graphs mobile layout and responsiveness (go-gitea#29597) Skip email domain check when admin users adds user manually (go-gitea#29522) Replace more `gt-` with `tw-`, update frontend docs (go-gitea#29595) Remove unnecessary ctxData for "attachments" template (go-gitea#29600) Adjust tailwind content globs (go-gitea#29596) Use flex wrap to layout the PR update button (go-gitea#29590) Make "/user/login" page redirect if the current user has signed in (go-gitea#29583) [skip ci] Updated translations via Crowdin Fix projects mode bugs (go-gitea#29593) Regenerate fomantic lockfile and build it with our browserslist (go-gitea#29560) Do not exceed display for the PR page buttons on smaller screens (go-gitea#29418) Add aria-label to the navbar menu button (go-gitea#29587)
2 parents 79032d9 + c481dba commit 810335f

Some content is hidden

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

60 files changed

+1644
-929
lines changed

.github/workflows/files-changed.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
- "Makefile"
4949
- ".golangci.yml"
5050
- ".editorconfig"
51+
- "options/locale/locale_en-US.ini"
5152
5253
frontend:
5354
- "**/*.js"

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ GO_DIRS := build cmd models modules routers services tests
147147
WEB_DIRS := web_src/js web_src/css
148148

149149
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github
150+
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
150151

151152
GO_SOURCES := $(wildcard *.go)
152153
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/options/bindata.go ! -path modules/public/bindata.go ! -path modules/templates/bindata.go)
@@ -426,7 +427,7 @@ lint-go-vet:
426427

427428
.PHONY: lint-editorconfig
428429
lint-editorconfig:
429-
$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates .github/workflows
430+
@$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES)
430431

431432
.PHONY: lint-actions
432433
lint-actions:
@@ -908,6 +909,7 @@ fomantic:
908909
cd $(FOMANTIC_WORK_DIR) && npm install --no-save
909910
cp -f $(FOMANTIC_WORK_DIR)/theme.config.less $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/theme.config
910911
cp -rf $(FOMANTIC_WORK_DIR)/_site $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/src/
912+
$(SED_INPLACE) -e 's/ overrideBrowserslist\r/ overrideBrowserslist: ["defaults"]\r/g' $(FOMANTIC_WORK_DIR)/node_modules/fomantic-ui/tasks/config/tasks.js
911913
cd $(FOMANTIC_WORK_DIR) && npx gulp -f node_modules/fomantic-ui/gulpfile.js build
912914
# fomantic uses "touchstart" as click event for some browsers, it's not ideal, so we force fomantic to always use "click" as click event
913915
$(SED_INPLACE) -e 's/clickEvent[ \t]*=/clickEvent = "click", unstableClickEvent =/g' $(FOMANTIC_WORK_DIR)/build/semantic.js

docs/content/contributing/guidelines-frontend.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h
4747
9. Avoid unnecessary `!important` in CSS, add comments to explain why it's necessary if it can't be avoided.
4848
10. Avoid mixing different events in one event listener, prefer to use individual event listeners for every event.
4949
11. Custom event names are recommended to use `ce-` prefix.
50-
12. Gitea's tailwind-style CSS classes use `gt-` prefix (`gt-relative`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`).
50+
12. Prefer using Tailwind CSS which is available via `tw-` prefix, e.g. `tw-relative`. Gitea's helper CSS classes use `gt-` prefix (`gt-df`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`).
5151
13. Avoid inline scripts & styles as much as possible, it's recommended to put JS code into JS files and use CSS classes. If inline scripts & styles are unavoidable, explain the reason why it can't be avoided.
5252

5353
### Accessibility / ARIA

docs/content/contributing/guidelines-frontend.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ HTML 页面由[Go HTML Template](https://pkg.go.dev/html/template)渲染。
4747
9. 避免在 CSS 中使用不必要的`!important`,如果无法避免,添加注释解释为什么需要它。
4848
10. 避免在一个事件监听器中混合不同的事件,优先为每个事件使用独立的事件监听器。
4949
11. 推荐使用自定义事件名称前缀`ce-`
50-
12. Gitea 的 tailwind-style CSS 类使用`gt-`前缀(`gt-relative`),Gitea 自身的私有框架级 CSS 类使用`g-`前缀(`g-modal-confirm`)。
50+
12. 建议使用 Tailwind CSS,它可以通过 `tw-` 前缀获得,例如 `tw-relative`. Gitea 自身的助手类 CSS 使用 `gt-` 前缀(`gt-df`),Gitea 自身的私有框架级 CSS 类使用 `g-` 前缀(`g-modal-confirm`)。
5151
13. 尽量避免内联脚本和样式,建议将JS代码放入JS文件中并使用CSS类。如果内联脚本和样式不可避免,请解释无法避免的原因。
5252

5353
### 可访问性 / ARIA

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ require (
113113
golang.org/x/text v0.14.0
114114
golang.org/x/tools v0.17.0
115115
google.golang.org/grpc v1.60.1
116-
google.golang.org/protobuf v1.32.0
116+
google.golang.org/protobuf v1.33.0
117117
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
118118
gopkg.in/ini.v1 v1.67.0
119119
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,8 +1308,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
13081308
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
13091309
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
13101310
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1311-
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
1312-
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
1311+
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
1312+
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
13131313
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
13141314
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
13151315
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

models/fixtures/repo_unit.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@
520520
id: 75
521521
repo_id: 1
522522
type: 8
523-
config: "{\"ProjectsMode\":\"all\"}"
524523
created_unix: 946684810
525524

526525
-

models/repo/repo.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,9 +412,11 @@ func (repo *Repository) MustGetUnit(ctx context.Context, tp unit.Type) *RepoUnit
412412
Config: new(ActionsConfig),
413413
}
414414
} else if tp == unit.TypeProjects {
415+
cfg := new(ProjectsConfig)
416+
cfg.ProjectsMode = ProjectsModeNone
415417
return &RepoUnit{
416418
Type: tp,
417-
Config: new(ProjectsConfig),
419+
Config: cfg,
418420
}
419421
}
420422

models/repo/repo_unit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (cfg *ProjectsConfig) GetProjectsMode() ProjectsMode {
236236
return cfg.ProjectsMode
237237
}
238238

239-
return ProjectsModeNone
239+
return ProjectsModeAll
240240
}
241241

242242
func (cfg *ProjectsConfig) IsProjectsAllowed(m ProjectsMode) bool {

models/user/email_address.go

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,37 +154,18 @@ func UpdateEmailAddress(ctx context.Context, email *EmailAddress) error {
154154

155155
var emailRegexp = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
156156

157-
// ValidateEmail check if email is a allowed address
157+
// ValidateEmail check if email is a valid & allowed address
158158
func ValidateEmail(email string) error {
159-
if len(email) == 0 {
160-
return ErrEmailInvalid{email}
161-
}
162-
163-
if !emailRegexp.MatchString(email) {
164-
return ErrEmailCharIsNotSupported{email}
165-
}
166-
167-
if email[0] == '-' {
168-
return ErrEmailInvalid{email}
169-
}
170-
171-
if _, err := mail.ParseAddress(email); err != nil {
172-
return ErrEmailInvalid{email}
173-
}
174-
175-
// if there is no allow list, then check email against block list
176-
if len(setting.Service.EmailDomainAllowList) == 0 &&
177-
validation.IsEmailDomainListed(setting.Service.EmailDomainBlockList, email) {
178-
return ErrEmailInvalid{email}
179-
}
180-
181-
// if there is an allow list, then check email against allow list
182-
if len(setting.Service.EmailDomainAllowList) > 0 &&
183-
!validation.IsEmailDomainListed(setting.Service.EmailDomainAllowList, email) {
184-
return ErrEmailInvalid{email}
159+
if err := validateEmailBasic(email); err != nil {
160+
return err
185161
}
162+
return validateEmailDomain(email)
163+
}
186164

187-
return nil
165+
// ValidateEmailForAdmin check if email is a valid address when admins manually add or edit users
166+
func ValidateEmailForAdmin(email string) error {
167+
return validateEmailBasic(email)
168+
// In this case we do not need to check the email domain
188169
}
189170

190171
func GetEmailAddressByEmail(ctx context.Context, email string) (*EmailAddress, error) {
@@ -534,3 +515,41 @@ func ActivateUserEmail(ctx context.Context, userID int64, email string, activate
534515

535516
return committer.Commit()
536517
}
518+
519+
// validateEmailBasic checks whether the email complies with the rules
520+
func validateEmailBasic(email string) error {
521+
if len(email) == 0 {
522+
return ErrEmailInvalid{email}
523+
}
524+
525+
if !emailRegexp.MatchString(email) {
526+
return ErrEmailCharIsNotSupported{email}
527+
}
528+
529+
if email[0] == '-' {
530+
return ErrEmailInvalid{email}
531+
}
532+
533+
if _, err := mail.ParseAddress(email); err != nil {
534+
return ErrEmailInvalid{email}
535+
}
536+
537+
return nil
538+
}
539+
540+
// validateEmailDomain checks whether the email domain is allowed or blocked
541+
func validateEmailDomain(email string) error {
542+
// if there is no allow list, then check email against block list
543+
if len(setting.Service.EmailDomainAllowList) == 0 &&
544+
validation.IsEmailDomainListed(setting.Service.EmailDomainBlockList, email) {
545+
return ErrEmailInvalid{email}
546+
}
547+
548+
// if there is an allow list, then check email against allow list
549+
if len(setting.Service.EmailDomainAllowList) > 0 &&
550+
!validation.IsEmailDomainListed(setting.Service.EmailDomainAllowList, email) {
551+
return ErrEmailInvalid{email}
552+
}
553+
554+
return nil
555+
}

models/user/user.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,16 @@ type CreateUserOverwriteOptions struct {
586586

587587
// CreateUser creates record of a new user.
588588
func CreateUser(ctx context.Context, u *User, overwriteDefault ...*CreateUserOverwriteOptions) (err error) {
589+
return createUser(ctx, u, false, overwriteDefault...)
590+
}
591+
592+
// AdminCreateUser is used by admins to manually create users
593+
func AdminCreateUser(ctx context.Context, u *User, overwriteDefault ...*CreateUserOverwriteOptions) (err error) {
594+
return createUser(ctx, u, true, overwriteDefault...)
595+
}
596+
597+
// createUser creates record of a new user.
598+
func createUser(ctx context.Context, u *User, createdByAdmin bool, overwriteDefault ...*CreateUserOverwriteOptions) (err error) {
589599
if err = IsUsableUsername(u.Name); err != nil {
590600
return err
591601
}
@@ -639,8 +649,14 @@ func CreateUser(ctx context.Context, u *User, overwriteDefault ...*CreateUserOve
639649
return err
640650
}
641651

642-
if err := ValidateEmail(u.Email); err != nil {
643-
return err
652+
if createdByAdmin {
653+
if err := ValidateEmailForAdmin(u.Email); err != nil {
654+
return err
655+
}
656+
} else {
657+
if err := ValidateEmail(u.Email); err != nil {
658+
return err
659+
}
644660
}
645661

646662
ctx, committer, err := db.TxContext(ctx)

modules/base/natural_sort.go

Lines changed: 4 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,85 +4,12 @@
44
package base
55

66
import (
7-
"math/big"
8-
"unicode/utf8"
7+
"golang.org/x/text/collate"
8+
"golang.org/x/text/language"
99
)
1010

1111
// NaturalSortLess compares two strings so that they could be sorted in natural order
1212
func NaturalSortLess(s1, s2 string) bool {
13-
var i1, i2 int
14-
for {
15-
rune1, j1, end1 := getNextRune(s1, i1)
16-
rune2, j2, end2 := getNextRune(s2, i2)
17-
if end1 || end2 {
18-
return end1 != end2 && end1
19-
}
20-
dec1 := isDecimal(rune1)
21-
dec2 := isDecimal(rune2)
22-
var less, equal bool
23-
if dec1 && dec2 {
24-
i1, i2, less, equal = compareByNumbers(s1, i1, s2, i2)
25-
} else if !dec1 && !dec2 {
26-
equal = rune1 == rune2
27-
less = rune1 < rune2
28-
i1 = j1
29-
i2 = j2
30-
} else {
31-
return rune1 < rune2
32-
}
33-
if !equal {
34-
return less
35-
}
36-
}
37-
}
38-
39-
func getNextRune(str string, pos int) (rune, int, bool) {
40-
if pos < len(str) {
41-
r, w := utf8.DecodeRuneInString(str[pos:])
42-
// Fallback to ascii
43-
if r == utf8.RuneError {
44-
r = rune(str[pos])
45-
w = 1
46-
}
47-
return r, pos + w, false
48-
}
49-
return 0, pos, true
50-
}
51-
52-
func isDecimal(r rune) bool {
53-
return '0' <= r && r <= '9'
54-
}
55-
56-
func compareByNumbers(str1 string, pos1 int, str2 string, pos2 int) (i1, i2 int, less, equal bool) {
57-
d1, d2 := true, true
58-
var dec1, dec2 string
59-
for d1 || d2 {
60-
if d1 {
61-
r, j, end := getNextRune(str1, pos1)
62-
if !end && isDecimal(r) {
63-
dec1 += string(r)
64-
pos1 = j
65-
} else {
66-
d1 = false
67-
}
68-
}
69-
if d2 {
70-
r, j, end := getNextRune(str2, pos2)
71-
if !end && isDecimal(r) {
72-
dec2 += string(r)
73-
pos2 = j
74-
} else {
75-
d2 = false
76-
}
77-
}
78-
}
79-
less, equal = compareBigNumbers(dec1, dec2)
80-
return pos1, pos2, less, equal
81-
}
82-
83-
func compareBigNumbers(dec1, dec2 string) (less, equal bool) {
84-
d1, _ := big.NewInt(0).SetString(dec1, 10)
85-
d2, _ := big.NewInt(0).SetString(dec2, 10)
86-
cmp := d1.Cmp(d2)
87-
return cmp < 0, cmp == 0
13+
c := collate.New(language.English, collate.Numeric)
14+
return c.CompareString(s1, s2) < 0
8815
}

modules/base/natural_sort_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111

1212
func TestNaturalSortLess(t *testing.T) {
1313
test := func(s1, s2 string, less bool) {
14-
assert.Equal(t, less, NaturalSortLess(s1, s2))
14+
assert.Equal(t, less, NaturalSortLess(s1, s2), "s1=%q, s2=%q", s1, s2)
1515
}
1616
test("v1.20.0", "v1.2.0", false)
1717
test("v1.20.0", "v1.29.0", true)
@@ -20,4 +20,11 @@ func TestNaturalSortLess(t *testing.T) {
2020
test("a-1-a", "a-1-b", true)
2121
test("2", "12", true)
2222
test("a", "ab", true)
23+
24+
test("A", "b", true)
25+
test("a", "B", true)
26+
27+
test("cafe", "café", true)
28+
test("café", "cafe", false)
29+
test("caff", "café", false)
2330
}

options/locale/locale_en-US.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ env_config_keys = Environment Configuration
320320
env_config_keys_prompt = The following environment variables will also be applied to your configuration file:
321321

322322
[home]
323+
nav_menu = Navigation Menu
323324
uname_holder = Username or Email Address
324325
password_holder = Password
325326
switch_dashboard_context = Switch Dashboard Context
@@ -654,7 +655,7 @@ block.note.title = Optional note:
654655
block.note.info = The note is not visible to the blocked user.
655656
block.note.edit = Edit note
656657
block.list = Blocked users
657-
block.list.none = You have not blocked any users.
658+
block.list.none = You have not blocked any users.
658659
659660
[settings]
660661
profile = Profile

options/locale/locale_ja-JP.ini

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ footer.software=ソフトウェアについて
149149
footer.links=リンク
150150

151151
[heatmap]
152-
number_of_contributions_in_the_last_12_months=過去 12 か月間で %s 個の貢献
153-
no_contributions=貢献なし
152+
number_of_contributions_in_the_last_12_months=過去 12 か月間で %s 件の実績
153+
no_contributions=実績なし
154154
less=少
155155
more=多
156156

@@ -1510,7 +1510,7 @@ issues.role.member_helper=このユーザーはこのリポジトリを所有し
15101510
issues.role.collaborator=共同作業者
15111511
issues.role.collaborator_helper=このユーザーはリポジトリ上で共同作業するように招待されています。
15121512
issues.role.first_time_contributor=初めての貢献者
1513-
issues.role.first_time_contributor_helper=これは、このユーザーのリポジトリへの最初の貢献です
1513+
issues.role.first_time_contributor_helper=これは、このユーザーによるリポジトリへの最初の貢献です
15141514
issues.role.contributor=貢献者
15151515
issues.role.contributor_helper=このユーザーは以前にリポジトリにコミットしています。
15161516
issues.re_request_review=レビューを再依頼
@@ -2011,7 +2011,8 @@ settings.mirror_settings.docs.more_information_if_disabled=プッシュミラー
20112011
settings.mirror_settings.docs.doc_link_title=リポジトリをミラーリングするには?
20122012
settings.mirror_settings.docs.doc_link_pull_section=ドキュメントの「リモートリポジトリからのプル」セクション。
20132013
settings.mirror_settings.docs.pulling_remote_title=リモートリポジトリからのプル
2014-
settings.mirror_settings.mirrored_repository=同期するリポジトリ
2014+
settings.mirror_settings.mirrored_repository=ミラー元のリポジトリ
2015+
settings.mirror_settings.pushed_repository=プッシュ先のリポジトリ
20152016
settings.mirror_settings.direction=方向
20162017
settings.mirror_settings.direction.pull=プル
20172018
settings.mirror_settings.direction.push=プッシュ
@@ -3546,6 +3547,8 @@ runs.actors_no_select=すべてのアクター
35463547
runs.status_no_select=すべてのステータス
35473548
runs.no_results=一致する結果はありません。
35483549
runs.no_workflows=ワークフローはまだありません。
3550+
runs.no_workflows.quick_start=Gitea Actions の始め方がわからない? では<a target="_blank" rel="noopener noreferrer" href="%s">クイックスタートガイド</a>をご覧ください。
3551+
runs.no_workflows.documentation=Gitea Actions の詳細については、<a target="_blank" rel="noopener noreferrer" href="%s">ドキュメント</a>を参照してください。
35493552
runs.no_runs=ワークフローはまだ実行されていません。
35503553
runs.empty_commit_message=(空のコミットメッセージ)
35513554

0 commit comments

Comments
 (0)