Skip to content

Commit c95fa24

Browse files
authored
Merge branch 'main' into fix-token-lifetime
2 parents 4f5cbfe + a2e8bf5 commit c95fa24

File tree

7 files changed

+221
-47
lines changed

7 files changed

+221
-47
lines changed

modules/setting/actions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var (
2424
ZombieTaskTimeout time.Duration `ini:"ZOMBIE_TASK_TIMEOUT"`
2525
EndlessTaskTimeout time.Duration `ini:"ENDLESS_TASK_TIMEOUT"`
2626
AbandonedJobTimeout time.Duration `ini:"ABANDONED_JOB_TIMEOUT"`
27-
SkipWorkflowStrings []string `ìni:"SKIP_WORKFLOW_STRINGS"`
27+
SkipWorkflowStrings []string `ini:"SKIP_WORKFLOW_STRINGS"`
2828
}{
2929
Enabled: true,
3030
DefaultActionsURL: defaultActionsURLGitHub,

modules/setting/cron_test.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,56 @@ EXTEND = true
4141
assert.Equal(t, "white rabbit", extended.Second)
4242
assert.True(t, extended.Extend)
4343
}
44+
45+
// Test_getCronSettings2 tests that getCronSettings can not handle two levels of embedding
46+
func Test_getCronSettings2(t *testing.T) {
47+
type BaseStruct struct {
48+
Enabled bool
49+
RunAtStart bool
50+
Schedule string
51+
}
52+
53+
type Extended struct {
54+
BaseStruct
55+
Extend bool
56+
}
57+
type Extended2 struct {
58+
Extended
59+
Third string
60+
}
61+
62+
iniStr := `
63+
[cron.test]
64+
ENABLED = TRUE
65+
RUN_AT_START = TRUE
66+
SCHEDULE = @every 1h
67+
EXTEND = true
68+
THIRD = white rabbit
69+
`
70+
cfg, err := NewConfigProviderFromData(iniStr)
71+
assert.NoError(t, err)
72+
73+
extended := &Extended2{
74+
Extended: Extended{
75+
BaseStruct: BaseStruct{
76+
Enabled: false,
77+
RunAtStart: false,
78+
Schedule: "@every 72h",
79+
},
80+
Extend: false,
81+
},
82+
Third: "black rabbit",
83+
}
84+
85+
_, err = getCronSettings(cfg, "test", extended)
86+
assert.NoError(t, err)
87+
88+
// This confirms the first level of embedding works
89+
assert.Equal(t, "white rabbit", extended.Third)
90+
assert.True(t, extended.Extend)
91+
92+
// This confirms 2 levels of embedding doesn't work
93+
assert.False(t, extended.Enabled)
94+
assert.False(t, extended.RunAtStart)
95+
assert.Equal(t, "@every 72h", extended.Schedule)
96+
}

options/locale/locale_zh-CN.ini

Lines changed: 92 additions & 12 deletions
Large diffs are not rendered by default.

services/cron/tasks_extended.go

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -171,34 +171,35 @@ func registerDeleteOldSystemNotices() {
171171
})
172172
}
173173

174+
type GCLFSConfig struct {
175+
BaseConfig
176+
OlderThan time.Duration
177+
LastUpdatedMoreThanAgo time.Duration
178+
NumberToCheckPerRepo int64
179+
ProportionToCheckPerRepo float64
180+
}
181+
174182
func registerGCLFS() {
175183
if !setting.LFS.StartServer {
176184
return
177185
}
178-
type GCLFSConfig struct {
179-
OlderThanConfig
180-
LastUpdatedMoreThanAgo time.Duration
181-
NumberToCheckPerRepo int64
182-
ProportionToCheckPerRepo float64
183-
}
184186

185187
RegisterTaskFatal("gc_lfs", &GCLFSConfig{
186-
OlderThanConfig: OlderThanConfig{
187-
BaseConfig: BaseConfig{
188-
Enabled: false,
189-
RunAtStart: false,
190-
Schedule: "@every 24h",
191-
},
192-
// Only attempt to garbage collect lfs meta objects older than a week as the order of git lfs upload
193-
// and git object upload is not necessarily guaranteed. It's possible to imagine a situation whereby
194-
// an LFS object is uploaded but the git branch is not uploaded immediately, or there are some rapid
195-
// changes in new branches that might lead to lfs objects becoming temporarily unassociated with git
196-
// objects.
197-
//
198-
// It is likely that a week is potentially excessive but it should definitely be enough that any
199-
// unassociated LFS object is genuinely unassociated.
200-
OlderThan: 24 * time.Hour * 7,
188+
BaseConfig: BaseConfig{
189+
Enabled: false,
190+
RunAtStart: false,
191+
Schedule: "@every 24h",
201192
},
193+
// Only attempt to garbage collect lfs meta objects older than a week as the order of git lfs upload
194+
// and git object upload is not necessarily guaranteed. It's possible to imagine a situation whereby
195+
// an LFS object is uploaded but the git branch is not uploaded immediately, or there are some rapid
196+
// changes in new branches that might lead to lfs objects becoming temporarily unassociated with git
197+
// objects.
198+
//
199+
// It is likely that a week is potentially excessive but it should definitely be enough that any
200+
// unassociated LFS object is genuinely unassociated.
201+
OlderThan: 24 * time.Hour * 7,
202+
202203
// Only GC things that haven't been looked at in the past 3 days
203204
LastUpdatedMoreThanAgo: 24 * time.Hour * 3,
204205
NumberToCheckPerRepo: 100,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package cron
5+
6+
import (
7+
"testing"
8+
"time"
9+
10+
"code.gitea.io/gitea/modules/setting"
11+
"code.gitea.io/gitea/modules/test"
12+
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func Test_GCLFSConfig(t *testing.T) {
17+
cfg, err := setting.NewConfigProviderFromData(`
18+
[cron.gc_lfs]
19+
ENABLED = true
20+
RUN_AT_START = true
21+
SCHEDULE = "@every 2h"
22+
OLDER_THAN = "1h"
23+
LAST_UPDATED_MORE_THAN_AGO = "7h"
24+
NUMBER_TO_CHECK_PER_REPO = 10
25+
PROPORTION_TO_CHECK_PER_REPO = 0.1
26+
`)
27+
assert.NoError(t, err)
28+
defer test.MockVariableValue(&setting.CfgProvider, cfg)()
29+
30+
config := &GCLFSConfig{
31+
BaseConfig: BaseConfig{
32+
Enabled: false,
33+
RunAtStart: false,
34+
Schedule: "@every 24h",
35+
},
36+
OlderThan: 24 * time.Hour * 7,
37+
LastUpdatedMoreThanAgo: 24 * time.Hour * 3,
38+
NumberToCheckPerRepo: 100,
39+
ProportionToCheckPerRepo: 0.6,
40+
}
41+
42+
_, err = setting.GetCronSettings("gc_lfs", config)
43+
assert.NoError(t, err)
44+
assert.True(t, config.Enabled)
45+
assert.True(t, config.RunAtStart)
46+
assert.Equal(t, "@every 2h", config.Schedule)
47+
assert.Equal(t, 1*time.Hour, config.OlderThan)
48+
assert.Equal(t, 7*time.Hour, config.LastUpdatedMoreThanAgo)
49+
assert.Equal(t, int64(10), config.NumberToCheckPerRepo)
50+
assert.InDelta(t, 0.1, config.ProportionToCheckPerRepo, 0.001)
51+
}

web_src/css/markup/content.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.markup {
22
overflow: hidden;
3-
font-size: 16px;
3+
font-size: 14px; /* 14px for comments, overridden to 16px for .file-view below. */
44
line-height: 1.5 !important;
55
overflow-wrap: break-word;
66
}
@@ -318,6 +318,7 @@ In markup content, we always use bottom margin for all elements */
318318

319319
.file-view.markup {
320320
padding: 1em 2em;
321+
font-size: 16px;
321322
}
322323

323324
.file-view.markup:has(.file-not-rendered-prompt) {

web_src/css/repo.css

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,6 @@ td .commit-summary {
300300
min-width: 100px;
301301
}
302302

303-
.repository.new.issue .comment.form .content .markup {
304-
font-size: 14px;
305-
}
306-
307303
.repository.view.issue .instruct-toggle {
308304
display: inline-block;
309305
}
@@ -630,10 +626,6 @@ td .commit-summary {
630626
background: var(--color-light);
631627
}
632628

633-
.repository.view.issue .comment-list .comment .markup {
634-
font-size: 14px;
635-
}
636-
637629
.repository.view.issue .comment-list .comment .no-content {
638630
color: var(--color-text-light-2);
639631
font-style: italic;
@@ -723,10 +715,6 @@ td .commit-summary {
723715
text-align: center;
724716
}
725717

726-
.repository.compare.pull .markup {
727-
font-size: 14px;
728-
}
729-
730718
.repository.branches .commit-divergence .bar-group {
731719
position: relative;
732720
float: left;

0 commit comments

Comments
 (0)