Skip to content

Commit c947e43

Browse files
authored
Merge branch 'master' into 13764-delete-comment
2 parents 0bf69ef + 4353cf9 commit c947e43

File tree

7 files changed

+29
-21
lines changed

7 files changed

+29
-21
lines changed

models/lfs_lock.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ package models
77
import (
88
"fmt"
99
"path"
10-
"strconv"
1110
"strings"
1211
"time"
1312

1413
"code.gitea.io/gitea/modules/log"
15-
api "code.gitea.io/gitea/modules/structs"
1614

1715
"xorm.io/xorm"
1816
)
@@ -52,18 +50,6 @@ func cleanPath(p string) string {
5250
return path.Clean("/" + p)[1:]
5351
}
5452

55-
// APIFormat convert a Release to lfs.LFSLock
56-
func (l *LFSLock) APIFormat() *api.LFSLock {
57-
return &api.LFSLock{
58-
ID: strconv.FormatInt(l.ID, 10),
59-
Path: l.Path,
60-
LockedAt: l.Created.Round(time.Second),
61-
Owner: &api.LFSLockOwner{
62-
Name: l.Owner.DisplayName(),
63-
},
64-
}
65-
}
66-
6753
// CreateLFSLock creates a new lock.
6854
func CreateLFSLock(lock *LFSLock) (*LFSLock, error) {
6955
err := CheckLFSAccessForRepo(lock.Owner, lock.Repo, AccessModeWrite)

modules/convert/convert.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package convert
77

88
import (
99
"fmt"
10+
"strconv"
11+
"time"
1012

1113
"code.gitea.io/gitea/models"
1214
"code.gitea.io/gitea/modules/git"
@@ -365,3 +367,15 @@ func ToCommitStatus(status *models.CommitStatus) *api.Status {
365367

366368
return apiStatus
367369
}
370+
371+
// ToLFSLock convert a LFSLock to api.LFSLock
372+
func ToLFSLock(l *models.LFSLock) *api.LFSLock {
373+
return &api.LFSLock{
374+
ID: strconv.FormatInt(l.ID, 10),
375+
Path: l.Path,
376+
LockedAt: l.Created.Round(time.Second),
377+
Owner: &api.LFSLockOwner{
378+
Name: l.Owner.DisplayName(),
379+
},
380+
}
381+
}

modules/lfs/locks.go

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

1212
"code.gitea.io/gitea/models"
1313
"code.gitea.io/gitea/modules/context"
14+
"code.gitea.io/gitea/modules/convert"
1415
"code.gitea.io/gitea/modules/log"
1516
"code.gitea.io/gitea/modules/setting"
1617
api "code.gitea.io/gitea/modules/structs"
@@ -60,7 +61,7 @@ func handleLockListOut(ctx *context.Context, repo *models.Repository, lock *mode
6061
return
6162
}
6263
ctx.JSON(200, api.LFSLockList{
63-
Locks: []*api.LFSLock{lock.APIFormat()},
64+
Locks: []*api.LFSLock{convert.ToLFSLock(lock)},
6465
})
6566
}
6667

@@ -140,7 +141,7 @@ func GetListLockHandler(ctx *context.Context) {
140141
lockListAPI := make([]*api.LFSLock, len(lockList))
141142
next := ""
142143
for i, l := range lockList {
143-
lockListAPI[i] = l.APIFormat()
144+
lockListAPI[i] = convert.ToLFSLock(l)
144145
}
145146
if limit > 0 && len(lockList) == limit {
146147
next = strconv.Itoa(cursor + 1)
@@ -198,7 +199,7 @@ func PostLockHandler(ctx *context.Context) {
198199
if err != nil {
199200
if models.IsErrLFSLockAlreadyExist(err) {
200201
ctx.JSON(409, api.LFSLockError{
201-
Lock: lock.APIFormat(),
202+
Lock: convert.ToLFSLock(lock),
202203
Message: "already created lock",
203204
})
204205
return
@@ -216,7 +217,7 @@ func PostLockHandler(ctx *context.Context) {
216217
})
217218
return
218219
}
219-
ctx.JSON(201, api.LFSLockResponse{Lock: lock.APIFormat()})
220+
ctx.JSON(201, api.LFSLockResponse{Lock: convert.ToLFSLock(lock)})
220221
}
221222

222223
// VerifyLockHandler list locks for verification
@@ -274,9 +275,9 @@ func VerifyLockHandler(ctx *context.Context) {
274275
lockTheirsListAPI := make([]*api.LFSLock, 0, len(lockList))
275276
for _, l := range lockList {
276277
if l.Owner.ID == ctx.User.ID {
277-
lockOursListAPI = append(lockOursListAPI, l.APIFormat())
278+
lockOursListAPI = append(lockOursListAPI, convert.ToLFSLock(l))
278279
} else {
279-
lockTheirsListAPI = append(lockTheirsListAPI, l.APIFormat())
280+
lockTheirsListAPI = append(lockTheirsListAPI, convert.ToLFSLock(l))
280281
}
281282
}
282283
ctx.JSON(200, api.LFSLockListVerify{
@@ -340,5 +341,5 @@ func UnLockHandler(ctx *context.Context) {
340341
})
341342
return
342343
}
343-
ctx.JSON(200, api.LFSLockResponse{Lock: lock.APIFormat()})
344+
ctx.JSON(200, api.LFSLockResponse{Lock: convert.ToLFSLock(lock)})
344345
}

modules/structs/settings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type GeneralRepoSettings struct {
1212

1313
// GeneralUISettings contains global ui settings exposed by API
1414
type GeneralUISettings struct {
15+
DefaultTheme string `json:"default_theme"`
1516
AllowedReactions []string `json:"allowed_reactions"`
1617
}
1718

routers/api/v1/settings/settings.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func GetGeneralUISettings(ctx *context.APIContext) {
2323
// "200":
2424
// "$ref": "#/responses/GeneralUISettings"
2525
ctx.JSON(http.StatusOK, api.GeneralUISettings{
26+
DefaultTheme: setting.UI.DefaultTheme,
2627
AllowedReactions: setting.UI.Reactions,
2728
})
2829
}

templates/base/head.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>{{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} </title>
88
<link rel="manifest" href="{{AppSubUrl}}/manifest.json" crossorigin="use-credentials">
99
<meta name="theme-color" content="{{ThemeColorMetaTag}}">
10+
<meta name="default-theme" content="{{DefaultTheme}}" />
1011
<meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}{{MetaAuthor}}{{end}}" />
1112
<meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{MetaDescription}}{{end}}" />
1213
<meta name="keywords" content="{{MetaKeywords}}">

templates/swagger/v1_json.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13523,6 +13523,10 @@
1352313523
"type": "string"
1352413524
},
1352513525
"x-go-name": "AllowedReactions"
13526+
},
13527+
"default_theme": {
13528+
"type": "string",
13529+
"x-go-name": "DefaultTheme"
1352613530
}
1352713531
},
1352813532
"x-go-package": "code.gitea.io/gitea/modules/structs"

0 commit comments

Comments
 (0)