Skip to content

Commit 41f4130

Browse files
authored
Merge branch 'main' into lunny/feed_optimization
2 parents 7b3701a + 2cd2ae0 commit 41f4130

File tree

19 files changed

+261
-138
lines changed

19 files changed

+261
-138
lines changed

.github/workflows/release-tag-version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ jobs:
8888
# 1.2
8989
# 1.2.3
9090
tags: |
91+
type=semver,pattern={{version}}
9192
type=semver,pattern={{major}}
9293
type=semver,pattern={{major}}.{{minor}}
93-
type=semver,pattern={{version}}
9494
- name: Login to Docker Hub
9595
uses: docker/login-action@v3
9696
with:
@@ -126,9 +126,9 @@ jobs:
126126
# 1.2
127127
# 1.2.3
128128
tags: |
129+
type=semver,pattern={{version}}
129130
type=semver,pattern={{major}}
130131
type=semver,pattern={{major}}.{{minor}}
131-
type=semver,pattern={{version}}
132132
- name: Login to Docker Hub
133133
uses: docker/login-action@v3
134134
with:

cmd/web_acme.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ func runACME(listenAddr string, m http.Handler) error {
5454
altTLSALPNPort = p
5555
}
5656

57-
// FIXME: this path is not right, it uses "AppWorkPath" incorrectly, and writes the data into "AppWorkPath/https"
58-
// Ideally it should migrate to AppDataPath write to "AppDataPath/https"
59-
certmagic.Default.Storage = &certmagic.FileStorage{Path: setting.AcmeLiveDirectory}
60-
magic := certmagic.NewDefault()
6157
// Try to use private CA root if provided, otherwise defaults to system's trust
6258
var certPool *x509.CertPool
6359
if setting.AcmeCARoot != "" {
@@ -67,7 +63,13 @@ func runACME(listenAddr string, m http.Handler) error {
6763
log.Warn("Failed to parse CA Root certificate, using default CA trust: %v", err)
6864
}
6965
}
70-
myACME := certmagic.NewACMEIssuer(magic, certmagic.ACMEIssuer{
66+
// FIXME: this path is not right, it uses "AppWorkPath" incorrectly, and writes the data into "AppWorkPath/https"
67+
// Ideally it should migrate to AppDataPath write to "AppDataPath/https"
68+
// And one more thing, no idea why we should set the global default variables here
69+
// But it seems that the current ACME code needs these global variables to make renew work.
70+
// Otherwise, "renew" will use incorrect storage path
71+
certmagic.Default.Storage = &certmagic.FileStorage{Path: setting.AcmeLiveDirectory}
72+
certmagic.DefaultACME = certmagic.ACMEIssuer{
7173
CA: setting.AcmeURL,
7274
TrustedRoots: certPool,
7375
Email: setting.AcmeEmail,
@@ -77,8 +79,10 @@ func runACME(listenAddr string, m http.Handler) error {
7779
ListenHost: setting.HTTPAddr,
7880
AltTLSALPNPort: altTLSALPNPort,
7981
AltHTTPPort: altHTTPPort,
80-
})
82+
}
8183

84+
magic := certmagic.NewDefault()
85+
myACME := certmagic.NewACMEIssuer(magic, certmagic.DefaultACME)
8286
magic.Issuers = []certmagic.Issuer{myACME}
8387

8488
// this obtains certificates or renews them if necessary

models/organization/org_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ func GetUserOrgsList(ctx context.Context, user *user_model.User) ([]*MinimalOrg,
124124
if err := db.GetEngine(ctx).Select(columnsStr).
125125
Table("user").
126126
Where(builder.In("`user`.`id`", queryUserOrgIDs(user.ID, true))).
127+
OrderBy("`user`.lower_name ASC").
127128
Find(&orgs); err != nil {
128129
return nil, err
129130
}

models/repo/user_repo.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package repo
55

66
import (
77
"context"
8+
"strings"
89

910
"code.gitea.io/gitea/models/db"
1011
"code.gitea.io/gitea/models/perm"
@@ -149,9 +150,9 @@ func GetRepoAssignees(ctx context.Context, repo *Repository) (_ []*user_model.Us
149150
// If isShowFullName is set to true, also include full name prefix search
150151
func GetIssuePostersWithSearch(ctx context.Context, repo *Repository, isPull bool, search string, isShowFullName bool) ([]*user_model.User, error) {
151152
users := make([]*user_model.User, 0, 30)
152-
var prefixCond builder.Cond = builder.Like{"name", search + "%"}
153+
var prefixCond builder.Cond = builder.Like{"lower_name", strings.ToLower(search) + "%"}
153154
if isShowFullName {
154-
prefixCond = prefixCond.Or(builder.Like{"full_name", "%" + search + "%"})
155+
prefixCond = prefixCond.Or(db.BuildCaseInsensitiveLike("full_name", "%"+search+"%"))
155156
}
156157

157158
cond := builder.In("`user`.id",

models/repo/user_repo_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
user_model "code.gitea.io/gitea/models/user"
1313

1414
"github.com/stretchr/testify/assert"
15+
"github.com/stretchr/testify/require"
1516
)
1617

1718
func TestRepoAssignees(t *testing.T) {
@@ -38,3 +39,19 @@ func TestRepoAssignees(t *testing.T) {
3839
assert.NotContains(t, []int64{users[0].ID, users[1].ID, users[2].ID}, 15)
3940
}
4041
}
42+
43+
func TestGetIssuePostersWithSearch(t *testing.T) {
44+
assert.NoError(t, unittest.PrepareTestDatabase())
45+
46+
repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
47+
48+
users, err := repo_model.GetIssuePostersWithSearch(db.DefaultContext, repo2, false, "USER", false /* full name */)
49+
require.NoError(t, err)
50+
require.Len(t, users, 1)
51+
assert.Equal(t, "user2", users[0].Name)
52+
53+
users, err = repo_model.GetIssuePostersWithSearch(db.DefaultContext, repo2, false, "TW%O", true /* full name */)
54+
require.NoError(t, err)
55+
require.Len(t, users, 1)
56+
assert.Equal(t, "user2", users[0].Name)
57+
}

modules/setting/server.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,24 @@ func loadServerFrom(rootCfg ConfigProvider) {
169169
HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
170170
HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
171171

172+
// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version
173+
// if these are removed, the warning will not be shown
174+
if sec.HasKey("ENABLE_ACME") {
175+
EnableAcme = sec.Key("ENABLE_ACME").MustBool(false)
176+
} else {
177+
deprecatedSetting(rootCfg, "server", "ENABLE_LETSENCRYPT", "server", "ENABLE_ACME", "v1.19.0")
178+
EnableAcme = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
179+
}
180+
172181
Protocol = HTTP
173182
protocolCfg := sec.Key("PROTOCOL").String()
183+
if protocolCfg != "https" && EnableAcme {
184+
log.Fatal("ACME could only be used with HTTPS protocol")
185+
}
186+
174187
switch protocolCfg {
175188
case "https":
176189
Protocol = HTTPS
177-
178-
// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version
179-
// if these are removed, the warning will not be shown
180-
if sec.HasKey("ENABLE_ACME") {
181-
EnableAcme = sec.Key("ENABLE_ACME").MustBool(false)
182-
} else {
183-
deprecatedSetting(rootCfg, "server", "ENABLE_LETSENCRYPT", "server", "ENABLE_ACME", "v1.19.0")
184-
EnableAcme = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
185-
}
186190
if EnableAcme {
187191
AcmeURL = sec.Key("ACME_URL").MustString("")
188192
AcmeCARoot = sec.Key("ACME_CA_ROOT").MustString("")
@@ -210,6 +214,9 @@ func loadServerFrom(rootCfg ConfigProvider) {
210214
deprecatedSetting(rootCfg, "server", "LETSENCRYPT_EMAIL", "server", "ACME_EMAIL", "v1.19.0")
211215
AcmeEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("")
212216
}
217+
if AcmeEmail == "" {
218+
log.Fatal("ACME Email is not set (ACME_EMAIL).")
219+
}
213220
} else {
214221
CertFile = sec.Key("CERT_FILE").String()
215222
KeyFile = sec.Key("KEY_FILE").String()

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,8 @@ issues.filter_milestones = Filter Milestone
14651465
issues.filter_projects = Filter Project
14661466
issues.filter_labels = Filter Label
14671467
issues.filter_reviewers = Filter Reviewer
1468+
issues.filter_no_results = No results
1469+
issues.filter_no_results_placeholder = Try adjusting your search filters.
14681470
issues.new = New Issue
14691471
issues.new.title_empty = Title cannot be empty
14701472
issues.new.labels = Labels

options/locale/locale_ja-JP.ini

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,12 @@ show_only_public=公開のみ表示
385385

386386
issues.in_your_repos=あなたのリポジトリ
387387

388+
guide_title=アクティビティはありません
389+
guide_desc=現在フォロー中のリポジトリやユーザーがないため、表示するコンテンツがありません。 以下のリンクから、興味のあるリポジトリやユーザーを探すことができます。
390+
explore_repos=リポジトリを探す
391+
explore_users=ユーザーを探す
392+
empty_org=組織はまだありません。
393+
empty_repo=リポジトリはまだありません。
388394

389395
[explore]
390396
repos=リポジトリ
@@ -1348,6 +1354,8 @@ editor.new_branch_name_desc=新しいブランチ名…
13481354
editor.cancel=キャンセル
13491355
editor.filename_cannot_be_empty=ファイル名は空にできません。
13501356
editor.filename_is_invalid=`ファイル名が不正です: "%s"`
1357+
editor.commit_email=コミット メールアドレス
1358+
editor.invalid_commit_email=コミットに使うメールアドレスが正しくありません。
13511359
editor.branch_does_not_exist=このリポジトリにブランチ "%s" は存在しません。
13521360
editor.branch_already_exists=ブランチ "%s" は、このリポジトリに既に存在します。
13531361
editor.directory_is_a_file=ディレクトリ名 "%s" はすでにリポジトリ内のファイルで使用されています。
@@ -1693,7 +1701,9 @@ issues.time_estimate_invalid=見積時間のフォーマットが不正です
16931701
issues.start_tracking_history=が作業を開始 %s
16941702
issues.tracker_auto_close=タイマーは、このイシューがクローズされると自動的に終了します
16951703
issues.tracking_already_started=`<a href="%s">別のイシュー</a>で既にタイムトラッキングを開始しています!`
1704+
issues.stop_tracking=タイマー終了
16961705
issues.stop_tracking_history=が <b>%[1]s</b> の作業を終了 %[2]s
1706+
issues.cancel_tracking=破棄
16971707
issues.cancel_tracking_history=`がタイムトラッキングを中止 %s`
16981708
issues.del_time=このタイムログを削除
16991709
issues.add_time_history=が作業時間 <b>%[1]s</b> を追加 %[2]s
@@ -2329,6 +2339,8 @@ settings.event_fork=フォーク
23292339
settings.event_fork_desc=リポジトリがフォークされたとき。
23302340
settings.event_wiki=Wiki
23312341
settings.event_wiki_desc=Wikiページが作成・名前変更・編集・削除されたとき。
2342+
settings.event_statuses=ステータス
2343+
settings.event_statuses_desc=APIによってコミットのステータスが更新されたとき。
23322344
settings.event_release=リリース
23332345
settings.event_release_desc=リポジトリでリリースが作成・更新・削除されたとき。
23342346
settings.event_push=プッシュ
@@ -2876,6 +2888,14 @@ view_as_role=表示: %s
28762888
view_as_public_hint=READMEを公開ユーザーとして見ています。
28772889
view_as_member_hint=READMEをこの組織のメンバーとして見ています。
28782890

2891+
worktime=作業時間
2892+
worktime.date_range_start=期間 (自)
2893+
worktime.date_range_end=期間 (至)
2894+
worktime.query=集計
2895+
worktime.time=時間
2896+
worktime.by_repositories=リポジトリ別
2897+
worktime.by_milestones=マイルストーン別
2898+
worktime.by_members=メンバー別
28792899

28802900
[admin]
28812901
maintenance=メンテナンス

routers/api/v1/repo/collaborators.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package repo
77
import (
88
"errors"
99
"net/http"
10+
"strings"
1011

1112
"code.gitea.io/gitea/models/perm"
1213
access_model "code.gitea.io/gitea/models/perm/access"
@@ -274,12 +275,13 @@ func GetRepoPermissions(ctx *context.APIContext) {
274275
// "403":
275276
// "$ref": "#/responses/forbidden"
276277

277-
if !ctx.Doer.IsAdmin && ctx.Doer.LoginName != ctx.PathParam("collaborator") && !ctx.IsUserRepoAdmin() {
278+
collaboratorUsername := ctx.PathParam("collaborator")
279+
if !ctx.Doer.IsAdmin && ctx.Doer.LowerName != strings.ToLower(collaboratorUsername) && !ctx.IsUserRepoAdmin() {
278280
ctx.APIError(http.StatusForbidden, "Only admins can query all permissions, repo admins can query all repo permissions, collaborators can query only their own")
279281
return
280282
}
281283

282-
collaborator, err := user_model.GetUserByName(ctx, ctx.PathParam("collaborator"))
284+
collaborator, err := user_model.GetUserByName(ctx, collaboratorUsername)
283285
if err != nil {
284286
if user_model.IsErrUserNotExist(err) {
285287
ctx.APIError(http.StatusNotFound, err)

routers/web/devtest/mock_actions.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,22 @@ func generateMockStepsLog(logCur actions.LogCursor) (stepsLog []*actions.ViewSte
5252
return stepsLog
5353
}
5454

55+
func MockActionsView(ctx *context.Context) {
56+
ctx.Data["RunID"] = ctx.PathParam("run")
57+
ctx.Data["JobID"] = ctx.PathParam("job")
58+
ctx.HTML(http.StatusOK, "devtest/repo-action-view")
59+
}
60+
5561
func MockActionsRunsJobs(ctx *context.Context) {
56-
req := web.GetForm(ctx).(*actions.ViewRequest)
62+
runID := ctx.PathParamInt64("run")
5763

64+
req := web.GetForm(ctx).(*actions.ViewRequest)
5865
resp := &actions.ViewResponse{}
5966
resp.State.Run.TitleHTML = `mock run title <a href="/">link</a>`
6067
resp.State.Run.Status = actions_model.StatusRunning.String()
61-
resp.State.Run.CanCancel = true
68+
resp.State.Run.CanCancel = runID == 10
69+
resp.State.Run.CanApprove = runID == 20
70+
resp.State.Run.CanRerun = runID == 30
6271
resp.State.Run.CanDeleteArtifact = true
6372
resp.State.Run.WorkflowID = "workflow-id"
6473
resp.State.Run.WorkflowLink = "./workflow-link"
@@ -85,6 +94,29 @@ func MockActionsRunsJobs(ctx *context.Context) {
8594
Size: 1024 * 1024,
8695
Status: "completed",
8796
})
97+
98+
resp.State.Run.Jobs = append(resp.State.Run.Jobs, &actions.ViewJob{
99+
ID: runID * 10,
100+
Name: "job 100",
101+
Status: actions_model.StatusRunning.String(),
102+
CanRerun: true,
103+
Duration: "1h",
104+
})
105+
resp.State.Run.Jobs = append(resp.State.Run.Jobs, &actions.ViewJob{
106+
ID: runID*10 + 1,
107+
Name: "job 101",
108+
Status: actions_model.StatusWaiting.String(),
109+
CanRerun: false,
110+
Duration: "2h",
111+
})
112+
resp.State.Run.Jobs = append(resp.State.Run.Jobs, &actions.ViewJob{
113+
ID: runID*10 + 2,
114+
Name: "job 102",
115+
Status: actions_model.StatusFailure.String(),
116+
CanRerun: false,
117+
Duration: "3h",
118+
})
119+
88120
resp.State.CurrentJob.Steps = append(resp.State.CurrentJob.Steps, &actions.ViewJobStep{
89121
Summary: "step 0 (mock slow)",
90122
Duration: time.Hour.String(),

0 commit comments

Comments
 (0)