Skip to content

Commit e127fe5

Browse files
authored
Merge branch 'main' into main
2 parents 43fc2ae + 816e46e commit e127fe5

Some content is hidden

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

49 files changed

+995
-231
lines changed

CHANGELOG.md

Lines changed: 448 additions & 1 deletion
Large diffs are not rendered by default.

cmd/dump.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ func addRecursiveExclude(w archiver.Writer, insidePath, absPath string, excludeA
452452
return err
453453
}
454454
for _, file := range files {
455-
currentAbsPath := path.Join(absPath, file.Name())
455+
currentAbsPath := filepath.Join(absPath, file.Name())
456456
currentInsidePath := path.Join(insidePath, file.Name())
457457
if file.IsDir() {
458458
if !util.SliceContainsString(excludeAbsPath, currentAbsPath) {

custom/conf/app.example.ini

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,8 +1016,8 @@ LEVEL = Info
10161016
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
10171017
;ALLOWED_TYPES =
10181018
;;
1019-
;; Max size of each file in megabytes. Defaults to 3MB
1020-
;FILE_MAX_SIZE = 3
1019+
;; Max size of each file in megabytes. Defaults to 50MB
1020+
;FILE_MAX_SIZE = 50
10211021
;;
10221022
;; Max number of files per upload. Defaults to 5
10231023
;MAX_FILES = 5
@@ -1821,8 +1821,8 @@ LEVEL = Info
18211821
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
18221822
;ALLOWED_TYPES = .csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip
18231823
;;
1824-
;; Max size of each file. Defaults to 4MB
1825-
;MAX_SIZE = 4
1824+
;; Max size of each file. Defaults to 2048MB
1825+
;MAX_SIZE = 2048
18261826
;;
18271827
;; Max number of files per upload. Defaults to 5
18281828
;MAX_FILES = 5
@@ -2583,6 +2583,8 @@ LEVEL = Info
25832583
;ENDLESS_TASK_TIMEOUT = 3h
25842584
;; Timeout to cancel the jobs which have waiting status, but haven't been picked by a runner for a long time
25852585
;ABANDONED_JOB_TIMEOUT = 24h
2586+
;; Strings committers can place inside a commit message to skip executing the corresponding actions workflow
2587+
;SKIP_WORKFLOW_STRINGS = [skip ci],[ci skip],[no ci],[skip actions],[actions skip]
25862588

25872589
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25882590
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ In addition, there is _`StaticRootPath`_ which can be set as a built-in at build
146146
- `ENABLED`: **true**: Whether repository file uploads are enabled
147147
- `TEMP_PATH`: **data/tmp/uploads**: Path for uploads (content gets deleted on Gitea restart)
148148
- `ALLOWED_TYPES`: **_empty_**: Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
149-
- `FILE_MAX_SIZE`: **3**: Max size of each file in megabytes.
149+
- `FILE_MAX_SIZE`: **50**: Max size of each file in megabytes.
150150
- `MAX_FILES`: **5**: Max number of files per upload
151151

152152
### Repository - Release (`repository.release`)
@@ -823,7 +823,7 @@ Default templates for project boards:
823823

824824
- `ENABLED`: **true**: Whether issue and pull request attachments are enabled.
825825
- `ALLOWED_TYPES`: **.csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip**: Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
826-
- `MAX_SIZE`: **4**: Maximum size (MB).
826+
- `MAX_SIZE`: **2048**: Maximum size (MB).
827827
- `MAX_FILES`: **5**: Maximum number of attachments that can be uploaded at once.
828828
- `STORAGE_TYPE`: **local**: Storage type for attachments, `local` for local disk or `minio` for s3 compatible object storage service, default is `local` or other name defined with `[storage.xxx]`
829829
- `SERVE_DIRECT`: **false**: Allows the storage driver to redirect to authenticated URLs to serve files directly. Currently, only Minio/S3 is supported via signed URLs, local does nothing.
@@ -1396,6 +1396,7 @@ PROXY_HOSTS = *.i.8713187.xyz
13961396
- `ZOMBIE_TASK_TIMEOUT`: **10m**: Timeout to stop the task which have running status, but haven't been updated for a long time
13971397
- `ENDLESS_TASK_TIMEOUT`: **3h**: Timeout to stop the tasks which have running status and continuous updates, but don't end for a long time
13981398
- `ABANDONED_JOB_TIMEOUT`: **24h**: Timeout to cancel the jobs which have waiting status, but haven't been picked by a runner for a long time
1399+
- `SKIP_WORKFLOW_STRINGS`: **[skip ci],[ci skip],[no ci],[skip actions],[actions skip]**: Strings committers can place inside a commit message to skip executing the corresponding actions workflow
13991400

14001401
`DEFAULT_ACTIONS_URL` indicates where the Gitea Actions runners should find the actions with relative path.
14011402
For example, `uses: actions/checkout@v3` means `https://github.com/actions/checkout@v3` since the value of `DEFAULT_ACTIONS_URL` is `github`.

docs/content/administration/config-cheat-sheet.zh-cn.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ menu:
145145
- `ENABLED`: **true**: 是否启用仓库文件上传。
146146
- `TEMP_PATH`: **data/tmp/uploads**: 文件上传的临时保存路径(在Gitea重启的时候该目录会被清空)。
147147
- `ALLOWED_TYPES`: **_empty_**: 以逗号分割的列表,代表支持上传的文件类型。(`.zip`), mime类型 (`text/plain`) or 通配符类型 (`image/*`, `audio/*`, `video/*`). 为空或者 `*/*`代表允许所有类型文件。
148-
- `FILE_MAX_SIZE`: **3**: 每个文件的最大大小(MB)。
148+
- `FILE_MAX_SIZE`: **50**: 每个文件的最大大小(MB)。
149149
- `MAX_FILES`: **5**: 每次上传的最大文件数。
150150

151151
### 仓库 - 版本发布 (`repository.release`)
@@ -783,7 +783,7 @@ Gitea 创建以下非唯一队列:
783783

784784
- `ENABLED`: **true**: 是否允许用户上传附件。
785785
- `ALLOWED_TYPES`: **.csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip**: 允许的文件扩展名(`.zip`)、mime 类型(`text/plain`)或通配符类型(`image/*``audio/*``video/*`)的逗号分隔列表。空值或 `*/*` 允许所有类型。
786-
- `MAX_SIZE`: **4**: 附件的最大限制(MB)。
786+
- `MAX_SIZE`: **2048**: 附件的最大限制(MB)。
787787
- `MAX_FILES`: **5**: 一次最多上传的附件数量。
788788
- `STORAGE_TYPE`: **local**: 附件的存储类型,`local` 表示本地磁盘,`minio` 表示兼容 S3 的对象存储服务,如果未设置将使用默认值 `local` 或其他在 `[storage.xxx]` 中定义的名称。
789789
- `SERVE_DIRECT`: **false**: 允许存储驱动器重定向到经过身份验证的 URL 以直接提供文件。目前,只支持 Minio/S3 通过签名 URL 提供支持,local 不会执行任何操作。

models/issues/comment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func (c *Comment) AfterLoad(session *xorm.Session) {
350350

351351
// LoadPoster loads comment poster
352352
func (c *Comment) LoadPoster(ctx context.Context) (err error) {
353-
if c.PosterID <= 0 || c.Poster != nil {
353+
if c.Poster != nil {
354354
return nil
355355
}
356356

models/repo/repo_list.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,12 @@ func AccessibleRepositoryCondition(user *user_model.User, unitType unit.Type) bu
652652
userOrgTeamUnitRepoCond("`repository`.id", user.ID, unitType),
653653
)
654654
}
655-
cond = cond.Or(
656-
// 4. Repositories that we directly own
657-
builder.Eq{"`repository`.owner_id": user.ID},
655+
// 4. Repositories that we directly own
656+
cond = cond.Or(builder.Eq{"`repository`.owner_id": user.ID})
657+
if !user.IsRestricted {
658658
// 5. Be able to see all public repos in private organizations that we are an org_user of
659-
userOrgPublicRepoCond(user.ID),
660-
)
659+
cond = cond.Or(userOrgPublicRepoCond(user.ID))
660+
}
661661
}
662662

663663
return cond

models/system/setting.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,24 +115,26 @@ func (d *dbConfigCachedGetter) GetValue(ctx context.Context, key string) (v stri
115115

116116
func (d *dbConfigCachedGetter) GetRevision(ctx context.Context) int {
117117
d.mu.RLock()
118-
defer d.mu.RUnlock()
119-
if time.Since(d.cacheTime) < time.Second {
120-
return d.revision
118+
cachedDuration := time.Since(d.cacheTime)
119+
cachedRevision := d.revision
120+
d.mu.RUnlock()
121+
122+
if cachedDuration < time.Second {
123+
return cachedRevision
121124
}
125+
126+
d.mu.Lock()
127+
defer d.mu.Unlock()
122128
if GetRevision(ctx) != d.revision {
123-
d.mu.RUnlock()
124-
d.mu.Lock()
125129
rev, set, err := GetAllSettings(ctx)
126130
if err != nil {
127131
log.Error("Unable to get all settings: %v", err)
128132
} else {
129-
d.cacheTime = time.Now()
130133
d.revision = rev
131134
d.settings = set
132135
}
133-
d.mu.Unlock()
134-
d.mu.RLock()
135136
}
137+
d.cacheTime = time.Now()
136138
return d.revision
137139
}
138140

modules/graceful/context.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import (
77
"context"
88
)
99

10+
// Shutdown procedure:
11+
// * cancel ShutdownContext: the registered context consumers have time to do their cleanup (they could use the hammer context)
12+
// * cancel HammerContext: the all context consumers have limited time to do their cleanup (wait for a few seconds)
13+
// * cancel TerminateContext: the registered context consumers have time to do their cleanup (but they shouldn't use shutdown/hammer context anymore)
14+
// * cancel manager context
15+
// If the shutdown is triggered again during the shutdown procedure, the hammer context will be canceled immediately to force to shut down.
16+
1017
// ShutdownContext returns a context.Context that is Done at shutdown
1118
// Callers using this context should ensure that they are registered as a running server
1219
// in order that they are waited for.

modules/graceful/manager.go

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ type RunCanceler interface {
3939
// and add a function to call manager.InformCleanup if it's not going to be used
4040
const numberOfServersToCreate = 4
4141

42-
// Manager represents the graceful server manager interface
43-
var manager *Manager
44-
45-
var initOnce = sync.Once{}
42+
var (
43+
manager *Manager
44+
initOnce sync.Once
45+
)
4646

4747
// GetManager returns the Manager
4848
func GetManager() *Manager {
@@ -147,12 +147,12 @@ func (g *Manager) doShutdown() {
147147
go g.doHammerTime(setting.GracefulHammerTime)
148148
}
149149
go func() {
150-
g.WaitForServers()
150+
g.runningServerWaitGroup.Wait()
151151
// Mop up any remaining unclosed events.
152152
g.doHammerTime(0)
153153
<-time.After(1 * time.Second)
154154
g.doTerminate()
155-
g.WaitForTerminate()
155+
g.terminateWaitGroup.Wait()
156156
g.lock.Lock()
157157
g.managerCtxCancel()
158158
g.lock.Unlock()
@@ -199,55 +199,26 @@ func (g *Manager) IsChild() bool {
199199
}
200200

201201
// IsShutdown returns a channel which will be closed at shutdown.
202-
// The order of closure is IsShutdown, IsHammer (potentially), IsTerminate
202+
// The order of closure is shutdown, hammer (potentially), terminate
203203
func (g *Manager) IsShutdown() <-chan struct{} {
204204
return g.shutdownCtx.Done()
205205
}
206206

207-
// IsHammer returns a channel which will be closed at hammer
208-
// The order of closure is IsShutdown, IsHammer (potentially), IsTerminate
207+
// IsHammer returns a channel which will be closed at hammer.
209208
// Servers running within the running server wait group should respond to IsHammer
210209
// if not shutdown already
211210
func (g *Manager) IsHammer() <-chan struct{} {
212211
return g.hammerCtx.Done()
213212
}
214213

215-
// IsTerminate returns a channel which will be closed at terminate
216-
// The order of closure is IsShutdown, IsHammer (potentially), IsTerminate
217-
// IsTerminate will only close once all running servers have stopped
218-
func (g *Manager) IsTerminate() <-chan struct{} {
219-
return g.terminateCtx.Done()
220-
}
221-
222214
// ServerDone declares a running server done and subtracts one from the
223215
// running server wait group. Users probably do not want to call this
224216
// and should use one of the RunWithShutdown* functions
225217
func (g *Manager) ServerDone() {
226218
g.runningServerWaitGroup.Done()
227219
}
228220

229-
// WaitForServers waits for all running servers to finish. Users should probably
230-
// instead use AtTerminate or IsTerminate
231-
func (g *Manager) WaitForServers() {
232-
g.runningServerWaitGroup.Wait()
233-
}
234-
235-
// WaitForTerminate waits for all terminating actions to finish.
236-
// Only the main go-routine should use this
237-
func (g *Manager) WaitForTerminate() {
238-
g.terminateWaitGroup.Wait()
239-
}
240-
241-
func (g *Manager) getState() state {
242-
g.lock.RLock()
243-
defer g.lock.RUnlock()
244-
return g.state
245-
}
246-
247221
func (g *Manager) setStateTransition(old, new state) bool {
248-
if old != g.getState() {
249-
return false
250-
}
251222
g.lock.Lock()
252223
if g.state != old {
253224
g.lock.Unlock()
@@ -258,13 +229,6 @@ func (g *Manager) setStateTransition(old, new state) bool {
258229
return true
259230
}
260231

261-
func (g *Manager) setState(st state) {
262-
g.lock.Lock()
263-
defer g.lock.Unlock()
264-
265-
g.state = st
266-
}
267-
268232
// InformCleanup tells the cleanup wait group that we have either taken a listener or will not be taking a listener.
269233
// At the moment the total number of servers (numberOfServersToCreate) are pre-defined as a const before global init,
270234
// so this function MUST be called if a server is not used.

modules/graceful/manager_unix.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ func (g *Manager) start(ctx context.Context) {
107107
defer pprof.SetGoroutineLabels(ctx)
108108

109109
// Set the running state & handle signals
110-
g.setState(stateRunning)
110+
if !g.setStateTransition(stateInit, stateRunning) {
111+
panic("invalid graceful manager state: transition from init to running failed")
112+
}
111113
g.notify(statusMsg("Starting Gitea"))
112114
g.notify(pidMsg())
113115
go g.handleSignals(g.managerCtx)

modules/graceful/manager_windows.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ func (g *Manager) start() {
8585
g.shutdownRequested = make(chan struct{})
8686

8787
// Set the running state
88-
g.setState(stateRunning)
88+
if !g.setStateTransition(stateInit, stateRunning) {
89+
panic("invalid graceful manager state: transition from init to running failed")
90+
}
8991
if skip, _ := strconv.ParseBool(os.Getenv("SKIP_MINWINSVC")); skip {
9092
log.Trace("Skipping SVC check as SKIP_MINWINSVC is set")
9193
return

modules/graceful/net_unix.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,8 @@ func CloseProvidedListeners() error {
150150
return returnableError
151151
}
152152

153-
// DefaultGetListener obtains a listener for the local network address. The network must be
154-
// a stream-oriented network: "tcp", "tcp4", "tcp6", "unix" or "unixpacket". It
155-
// returns an provided net.Listener for the matching network and address, or
156-
// creates a new one using net.Listen. This function can be replaced by changing the
157-
// GetListener variable at the top of this file, for example to listen on an onion service using
158-
// github.com/cretz/bine
153+
// DefaultGetListener obtains a listener for the stream-oriented local network address:
154+
// "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
159155
func DefaultGetListener(network, address string) (net.Listener, error) {
160156
// Add a deferral to say that we've tried to grab a listener
161157
defer GetManager().InformCleanup()

modules/graceful/net_windows.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ package graceful
1010
import "net"
1111

1212
// DefaultGetListener obtains a listener for the local network address.
13-
// On windows this is basically just a shim around net.Listen. This function
14-
// can be replaced by changing the GetListener variable at the top of this file,
15-
// for example to listen on an onion service using github.com/cretz/bine
13+
// On windows this is basically just a shim around net.Listen.
1614
func DefaultGetListener(network, address string) (net.Listener, error) {
1715
// Add a deferral to say that we've tried to grab a listener
1816
defer GetManager().InformCleanup()

modules/graceful/server.go

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,11 @@ import (
2020
"code.gitea.io/gitea/modules/setting"
2121
)
2222

23-
var (
24-
// DefaultReadTimeOut default read timeout
25-
DefaultReadTimeOut time.Duration
26-
// DefaultWriteTimeOut default write timeout
27-
DefaultWriteTimeOut time.Duration
28-
// DefaultMaxHeaderBytes default max header bytes
29-
DefaultMaxHeaderBytes int
30-
// PerWriteWriteTimeout timeout for writes
31-
PerWriteWriteTimeout = 30 * time.Second
32-
// PerWriteWriteTimeoutKbTime is a timeout taking account of how much there is to be written
33-
PerWriteWriteTimeoutKbTime = 10 * time.Second
34-
)
35-
36-
// GetListener returns a listener from a GetListener function, which must have the
37-
// signature: `func FunctioName(network, address string) (net.Listener, error)`.
38-
// This determines the implementation of net.Listener which the server will use.`
39-
// It is implemented in this way so that downstreams may specify the type of listener
40-
// they want to provide Gitea on by default, such as with a hidden service or a p2p network
41-
// No need to worry about "breaking" if there would be a refactoring for the Listeners. No compatibility-guarantee for this mechanism
23+
// GetListener returns a net listener
24+
// This determines the implementation of net.Listener which the server will use,
25+
// so that downstreams could provide their own Listener, such as with a hidden service or a p2p network
4226
var GetListener = DefaultGetListener
4327

44-
func init() {
45-
DefaultMaxHeaderBytes = 0 // use http.DefaultMaxHeaderBytes - which currently is 1 << 20 (1MB)
46-
}
47-
4828
// ServeFunction represents a listen.Accept loop
4929
type ServeFunction = func(net.Listener) error
5030

modules/graceful/server_http.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ import (
1313
func newHTTPServer(network, address, name string, handler http.Handler) (*Server, ServeFunction) {
1414
server := NewServer(network, address, name)
1515
httpServer := http.Server{
16-
ReadTimeout: DefaultReadTimeOut,
17-
WriteTimeout: DefaultWriteTimeOut,
18-
MaxHeaderBytes: DefaultMaxHeaderBytes,
19-
Handler: handler,
20-
BaseContext: func(net.Listener) context.Context { return GetManager().HammerContext() },
16+
Handler: handler,
17+
BaseContext: func(net.Listener) context.Context { return GetManager().HammerContext() },
2118
}
2219
server.OnShutdown = func() {
2320
httpServer.SetKeepAlivesEnabled(false)

modules/setting/actions.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ var (
2222
ZombieTaskTimeout time.Duration `ini:"ZOMBIE_TASK_TIMEOUT"`
2323
EndlessTaskTimeout time.Duration `ini:"ENDLESS_TASK_TIMEOUT"`
2424
AbandonedJobTimeout time.Duration `ini:"ABANDONED_JOB_TIMEOUT"`
25+
SkipWorkflowStrings []string `ìni:"SKIP_WORKFLOW_STRINGS"`
2526
}{
26-
Enabled: true,
27-
DefaultActionsURL: defaultActionsURLGitHub,
27+
Enabled: true,
28+
DefaultActionsURL: defaultActionsURLGitHub,
29+
SkipWorkflowStrings: []string{"[skip ci]", "[ci skip]", "[no ci]", "[skip actions]", "[actions skip]"},
2830
}
2931
)
3032

modules/setting/attachment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var Attachment = struct {
1313
}{
1414
Storage: &Storage{},
1515
AllowedTypes: ".csv,.docx,.fodg,.fodp,.fods,.fodt,.gif,.gz,.jpeg,.jpg,.log,.md,.mov,.mp4,.odf,.odg,.odp,.ods,.odt,.patch,.pdf,.png,.pptx,.svg,.tgz,.txt,.webm,.xls,.xlsx,.zip",
16-
MaxSize: 4,
16+
MaxSize: 2048,
1717
MaxFiles: 5,
1818
Enabled: true,
1919
}

0 commit comments

Comments
 (0)