Skip to content

Commit 772be15

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Add global setting how timestamps should be rendered (go-gitea#28657) [skip ci] Updated translations via Crowdin Upgrade xorm to new version which supported update join for all supported databases (go-gitea#28590) Fix: system webhooks API bug (go-gitea#28531) Fix alpine package files are not rebuilt (go-gitea#28638) Fix migration test (go-gitea#28659) Avoid cycle-redirecting user/login page (go-gitea#28636) Fix long package version names overflowing (go-gitea#28619)
2 parents d705bd2 + cdc33b2 commit 772be15

File tree

21 files changed

+136
-105
lines changed

21 files changed

+136
-105
lines changed

custom/conf/app.example.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,10 @@ LEVEL = Info
12441244
;; Change the sort type of the explore pages.
12451245
;; Default is "recentupdate", but you also have "alphabetically", "reverselastlogin", "newest", "oldest".
12461246
;EXPLORE_PAGING_DEFAULT_SORT = recentupdate
1247+
;;
1248+
;; The tense all timestamps should be rendered in. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) and `mixed`.
1249+
;; `mixed` means most timestamps are rendered in relative time (i.e. 2 days ago).
1250+
;PREFERRED_TIMESTAMP_TENSE = mixed
12471251

12481252
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12491253
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/administration/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
231231
- `ONLY_SHOW_RELEVANT_REPOS`: **false**: Whether to only show relevant repos on the explore page when no keyword is specified and default sorting is used.
232232
A repo is considered irrelevant if it's a fork or if it has no metadata (no description, no icon, no topic).
233233
- `EXPLORE_PAGING_DEFAULT_SORT`: **recentupdate**: Change the sort type of the explore pages. Valid values are "recentupdate", "alphabetically", "reverselastlogin", "newest" and "oldest"
234+
- `PREFERRED_TIMESTAMP_TENSE`: **mixed**: The tense all timestamps should be rendered in. Possible values are `absolute` time (i.e. 1970-01-01, 11:59) and `mixed`. `mixed` means most timestamps are rendered in relative time (i.e. 2 days ago).
234235

235236
### UI - Admin (`ui.admin`)
236237

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ require (
121121
mvdan.cc/xurls/v2 v2.5.0
122122
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
123123
xorm.io/builder v0.3.13
124-
xorm.io/xorm v1.3.4
124+
xorm.io/xorm v1.3.6
125125
)
126126

127127
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,5 +1510,5 @@ strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:
15101510
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
15111511
xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo=
15121512
xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
1513-
xorm.io/xorm v1.3.4 h1:vWFKzR3DhGUDl5b4srhUjhDwjxkZAc4C7BFszpu0swI=
1514-
xorm.io/xorm v1.3.4/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo=
1513+
xorm.io/xorm v1.3.6 h1:hfpWHkDIWWqUi8FRF2H2M9O8lO3Ov47rwFcS9gPzPkU=
1514+
xorm.io/xorm v1.3.6/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo=

models/auth/source.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,12 @@ func (opts FindSourcesOptions) ToConds() builder.Cond {
261261
// IsSSPIEnabled returns true if there is at least one activated login
262262
// source of type LoginSSPI
263263
func IsSSPIEnabled(ctx context.Context) bool {
264-
if !db.HasEngine {
265-
return false
266-
}
267-
268264
exist, err := db.Exist[Source](ctx, FindSourcesOptions{
269265
IsActive: util.OptionalBoolTrue,
270266
LoginType: SSPI,
271267
}.ToConds())
272268
if err != nil {
273-
log.Error("Active SSPI Sources: %v", err)
269+
log.Error("IsSSPIEnabled: failed to query active SSPI sources: %v", err)
274270
return false
275271
}
276272
return exist

models/db/engine.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ var (
2727
x *xorm.Engine
2828
tables []any
2929
initFuncs []func() error
30-
31-
// HasEngine specifies if we have a xorm.Engine
32-
HasEngine bool
3330
)
3431

3532
// Engine represents a xorm engine or session.

models/issues/comment.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,14 +1161,9 @@ func DeleteComment(ctx context.Context, comment *Comment) error {
11611161
// UpdateCommentsMigrationsByType updates comments' migrations information via given git service type and original id and poster id
11621162
func UpdateCommentsMigrationsByType(ctx context.Context, tp structs.GitServiceType, originalAuthorID string, posterID int64) error {
11631163
_, err := db.GetEngine(ctx).Table("comment").
1164-
Where(builder.In("issue_id",
1165-
builder.Select("issue.id").
1166-
From("issue").
1167-
InnerJoin("repository", "issue.repo_id = repository.id").
1168-
Where(builder.Eq{
1169-
"repository.original_service_type": tp,
1170-
}),
1171-
)).
1164+
Join("INNER", "issue", "issue.id = comment.issue_id").
1165+
Join("INNER", "repository", "issue.repo_id = repository.id").
1166+
Where("repository.original_service_type = ?", tp).
11721167
And("comment.original_author_id = ?", originalAuthorID).
11731168
Update(map[string]any{
11741169
"poster_id": posterID,

models/migrations/v1_22/v283_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ import (
77
"testing"
88

99
"code.gitea.io/gitea/models/migrations/base"
10+
11+
"github.com/stretchr/testify/assert"
1012
)
1113

1214
func Test_AddCombinedIndexToIssueUser(t *testing.T) {
13-
type IssueUser struct {
14-
UID int64 `xorm:"INDEX unique(uid_to_issue)"` // User ID.
15-
IssueID int64 `xorm:"INDEX unique(uid_to_issue)"`
15+
type IssueUser struct { // old struct
16+
ID int64 `xorm:"pk autoincr"`
17+
UID int64 `xorm:"INDEX"` // User ID.
18+
IssueID int64 `xorm:"INDEX"`
19+
IsRead bool
20+
IsMentioned bool
1621
}
1722

1823
// Prepare and load the testing database
1924
x, deferable := base.PrepareTestEnv(t, 0, new(IssueUser))
2025
defer deferable()
21-
if x == nil || t.Failed() {
22-
return
23-
}
2426

25-
if err := AddCombinedIndexToIssueUser(x); err != nil {
26-
t.Fatal(err)
27-
}
27+
assert.NoError(t, AddCombinedIndexToIssueUser(x))
2828
}

modules/setting/server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ func loadServerFrom(rootCfg ConfigProvider) {
341341
LandingPageURL = LandingPageOrganizations
342342
case "login":
343343
LandingPageURL = LandingPageLogin
344-
case "":
345-
case "home":
344+
case "", "home":
346345
LandingPageURL = LandingPageHome
347346
default:
348347
LandingPageURL = LandingPage(landingPage)

modules/setting/ui.go

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,35 @@ import (
77
"time"
88

99
"code.gitea.io/gitea/modules/container"
10+
"code.gitea.io/gitea/modules/log"
1011
)
1112

1213
// UI settings
1314
var UI = struct {
14-
ExplorePagingNum int
15-
SitemapPagingNum int
16-
IssuePagingNum int
17-
RepoSearchPagingNum int
18-
MembersPagingNum int
19-
FeedMaxCommitNum int
20-
FeedPagingNum int
21-
PackagesPagingNum int
22-
GraphMaxCommitNum int
23-
CodeCommentLines int
24-
ReactionMaxUserNum int
25-
MaxDisplayFileSize int64
26-
ShowUserEmail bool
27-
DefaultShowFullName bool
28-
DefaultTheme string
29-
Themes []string
30-
Reactions []string
31-
ReactionsLookup container.Set[string] `ini:"-"`
32-
CustomEmojis []string
33-
CustomEmojisMap map[string]string `ini:"-"`
34-
SearchRepoDescription bool
35-
OnlyShowRelevantRepos bool
36-
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`
15+
ExplorePagingNum int
16+
SitemapPagingNum int
17+
IssuePagingNum int
18+
RepoSearchPagingNum int
19+
MembersPagingNum int
20+
FeedMaxCommitNum int
21+
FeedPagingNum int
22+
PackagesPagingNum int
23+
GraphMaxCommitNum int
24+
CodeCommentLines int
25+
ReactionMaxUserNum int
26+
MaxDisplayFileSize int64
27+
ShowUserEmail bool
28+
DefaultShowFullName bool
29+
DefaultTheme string
30+
Themes []string
31+
Reactions []string
32+
ReactionsLookup container.Set[string] `ini:"-"`
33+
CustomEmojis []string
34+
CustomEmojisMap map[string]string `ini:"-"`
35+
SearchRepoDescription bool
36+
OnlyShowRelevantRepos bool
37+
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`
38+
PreferredTimestampTense string
3739

3840
AmbiguousUnicodeDetection bool
3941

@@ -67,23 +69,24 @@ var UI = struct {
6769
Keywords string
6870
} `ini:"ui.meta"`
6971
}{
70-
ExplorePagingNum: 20,
71-
SitemapPagingNum: 20,
72-
IssuePagingNum: 20,
73-
RepoSearchPagingNum: 20,
74-
MembersPagingNum: 20,
75-
FeedMaxCommitNum: 5,
76-
FeedPagingNum: 20,
77-
PackagesPagingNum: 20,
78-
GraphMaxCommitNum: 100,
79-
CodeCommentLines: 4,
80-
ReactionMaxUserNum: 10,
81-
MaxDisplayFileSize: 8388608,
82-
DefaultTheme: `gitea-auto`,
83-
Themes: []string{`gitea-auto`, `gitea-light`, `gitea-dark`},
84-
Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`},
85-
CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`},
86-
CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:"},
72+
ExplorePagingNum: 20,
73+
SitemapPagingNum: 20,
74+
IssuePagingNum: 20,
75+
RepoSearchPagingNum: 20,
76+
MembersPagingNum: 20,
77+
FeedMaxCommitNum: 5,
78+
FeedPagingNum: 20,
79+
PackagesPagingNum: 20,
80+
GraphMaxCommitNum: 100,
81+
CodeCommentLines: 4,
82+
ReactionMaxUserNum: 10,
83+
MaxDisplayFileSize: 8388608,
84+
DefaultTheme: `gitea-auto`,
85+
Themes: []string{`gitea-auto`, `gitea-light`, `gitea-dark`},
86+
Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`},
87+
CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`},
88+
CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:"},
89+
PreferredTimestampTense: "mixed",
8790

8891
AmbiguousUnicodeDetection: true,
8992

@@ -142,6 +145,10 @@ func loadUIFrom(rootCfg ConfigProvider) {
142145
UI.DefaultShowFullName = sec.Key("DEFAULT_SHOW_FULL_NAME").MustBool(false)
143146
UI.SearchRepoDescription = sec.Key("SEARCH_REPO_DESCRIPTION").MustBool(true)
144147

148+
if UI.PreferredTimestampTense != "mixed" && UI.PreferredTimestampTense != "absolute" {
149+
log.Fatal("ui.PREFERRED_TIMESTAMP_TENSE must be either 'mixed' or 'absolute'")
150+
}
151+
145152
// OnlyShowRelevantRepos=false is important for many private/enterprise instances,
146153
// because many private repositories do not have "description/topic", users just want to search by their names.
147154
UI.OnlyShowRelevantRepos = sec.Key("ONLY_SHOW_RELEVANT_REPOS").MustBool(false)

0 commit comments

Comments
 (0)