Skip to content

Commit 3d51f1b

Browse files
committed
Merge branch 'frontend-refactor' of github.com:wxiaoguang/gitea into frontend-refactor
2 parents f1eb378 + f27d1a8 commit 3d51f1b

File tree

47 files changed

+2808
-161
lines changed

Some content is hidden

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

47 files changed

+2808
-161
lines changed

custom/conf/app.example.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ PATH =
580580
;;
581581
;; (Go-Git only) Don't cache objects greater than this in memory. (Set to 0 to disable.)
582582
;LARGE_OBJECT_THRESHOLD = 1048576
583+
;; Set to true to forcibly set core.protectNTFS=false
584+
;DISABLE_CORE_PROTECT_NTFS=false
583585

584586
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
585587
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take ef
842842
- `VERBOSE_PUSH`: **true**: Print status information about pushes as they are being processed.
843843
- `VERBOSE_PUSH_DELAY`: **5s**: Only print verbose information if push takes longer than this delay.
844844
- `LARGE_OBJECT_THRESHOLD`: **1048576**: (Go-Git only), don't cache objects greater than this in memory. (Set to 0 to disable.)
845+
- `DISABLE_CORE_PROTECT_NTFS`: **false** Set to true to forcibly set `core.protectNTFS` to false.
845846
## Git - Timeout settings (`git.timeout`)
846847
- `DEFAUlT`: **360**: Git operations default timeout seconds.
847848
- `MIGRATE`: **600**: Migrate external repositories timeout seconds.

go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ require (
66
cloud.google.com/go v0.78.0 // indirect
77
code.gitea.io/gitea-vet v0.2.1
88
code.gitea.io/sdk/gitea v0.14.0
9-
gitea.com/go-chi/binding v0.0.0-20210301195521-1fe1c9a555e7
10-
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e
11-
gitea.com/go-chi/captcha v0.0.0-20210110083842-e7696c336a1e
12-
gitea.com/go-chi/session v0.0.0-20210913064732-2ac132b0fa07
9+
gitea.com/go-chi/binding v0.0.0-20211013065440-d16dc407c2be
10+
gitea.com/go-chi/cache v0.0.0-20211013020926-78790b11abf1
11+
gitea.com/go-chi/captcha v0.0.0-20211013065431-70641c1a35d5
12+
gitea.com/go-chi/session v0.0.0-20211013065435-7d334f340c09
1313
gitea.com/lunny/levelqueue v0.4.1
1414
github.com/Microsoft/go-winio v0.5.0 // indirect
1515
github.com/NYTimes/gziphandler v1.1.1
@@ -37,6 +37,7 @@ require (
3737
github.com/gliderlabs/ssh v0.3.3
3838
github.com/go-asn1-ber/asn1-ber v1.5.3 // indirect
3939
github.com/go-chi/chi v1.5.4
40+
github.com/go-chi/chi/v5 v5.0.4
4041
github.com/go-chi/cors v1.2.0
4142
github.com/go-enry/go-enry/v2 v2.7.1
4243
github.com/go-git/go-billy/v5 v5.3.1

go.sum

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@ code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFj
4141
code.gitea.io/sdk/gitea v0.14.0 h1:m4J352I3p9+bmJUfS+g0odeQzBY/5OXP91Gv6D4fnJ0=
4242
code.gitea.io/sdk/gitea v0.14.0/go.mod h1:89WiyOX1KEcvjP66sRHdu0RafojGo60bT9UqW17VbWs=
4343
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
44-
gitea.com/go-chi/binding v0.0.0-20210301195521-1fe1c9a555e7 h1:xCVJPY823C8RWpgMabTw2kOglDrg0iS3GcQU6wdwHkU=
45-
gitea.com/go-chi/binding v0.0.0-20210301195521-1fe1c9a555e7/go.mod h1:AyfTrwtfYN54R/HmVvMYPnSTenH5bVoyh8x6tBluxEA=
46-
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e h1:zgPGaf3kXP0cVm9J0l8ZA2+XDzILYATg0CXbihR6N+o=
44+
gitea.com/go-chi/binding v0.0.0-20211013065440-d16dc407c2be h1:IzSwPVzd2hE6e67ujY8ReBCrQ5IFNd0uiBmC7Ux5IaY=
45+
gitea.com/go-chi/binding v0.0.0-20211013065440-d16dc407c2be/go.mod h1:/vR0YjlusOYvosKYW7QKcSnrY0nPLe4RQ/DGi3+i/Do=
4746
gitea.com/go-chi/cache v0.0.0-20210110083709-82c4c9ce2d5e/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=
48-
gitea.com/go-chi/captcha v0.0.0-20210110083842-e7696c336a1e h1:YjaQU6XFicdhPN+MlGolcXO8seYY2+EY5g7vZPB17CQ=
49-
gitea.com/go-chi/captcha v0.0.0-20210110083842-e7696c336a1e/go.mod h1:nfA7JaGv3hbGQ1ktdhAsZhdS84qKffI8NMlHr+Opsog=
50-
gitea.com/go-chi/session v0.0.0-20210913064732-2ac132b0fa07 h1:1xF0xbIgDWnBB0iURAUFCoac4KfhGDdI7y7+3/8I8i4=
51-
gitea.com/go-chi/session v0.0.0-20210913064732-2ac132b0fa07/go.mod h1:Ozg8IchVNb/Udg+ui39iHRYqVHSvf3C99ixdpLR8Vu0=
47+
gitea.com/go-chi/cache v0.0.0-20211013020926-78790b11abf1 h1:Z7DcvTkxt8ovcENgPsQ7xzrGNSQmmIjGS9fJEb1l8jk=
48+
gitea.com/go-chi/cache v0.0.0-20211013020926-78790b11abf1/go.mod h1:k2V/gPDEtXGjjMGuBJiapffAXTv76H4snSmlJRLUhH0=
49+
gitea.com/go-chi/captcha v0.0.0-20211013065431-70641c1a35d5 h1:J/1i8u40TbcLP/w2w2KCkgW2PelIqYkD5UOwu8IOvVU=
50+
gitea.com/go-chi/captcha v0.0.0-20211013065431-70641c1a35d5/go.mod h1:hQ9SYHKdOX968wJglb/NMQ+UqpOKwW4L+EYdvkWjHSo=
51+
gitea.com/go-chi/session v0.0.0-20211013065435-7d334f340c09 h1:1+K+6uOXrnSfLHXvu8jpuoNEWA3/NULOlLSRZwaij+c=
52+
gitea.com/go-chi/session v0.0.0-20211013065435-7d334f340c09/go.mod h1:fc/pjt5EqNKgqQXYzcas1Z5L5whkZHyOvTA7OzWVJck=
5253
gitea.com/lunny/levelqueue v0.4.1 h1:RZ+AFx5gBsZuyqCvofhAkPQ9uaVDPJnsULoJZIYaJNw=
5354
gitea.com/lunny/levelqueue v0.4.1/go.mod h1:HBqmLbz56JWpfEGG0prskAV97ATNRoj5LDmPicD22hU=
5455
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
@@ -320,11 +321,11 @@ github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1T
320321
github.com/go-asn1-ber/asn1-ber v1.5.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
321322
github.com/go-asn1-ber/asn1-ber v1.5.3 h1:u7utq56RUFiynqUzgVMFDymapcOtQ/MZkh3H4QYkxag=
322323
github.com/go-asn1-ber/asn1-ber v1.5.3/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
323-
github.com/go-chi/chi v1.5.1/go.mod h1:REp24E+25iKvxgeTfHmdUoL5x15kBiDBlnIl5bCwe2k=
324324
github.com/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs=
325325
github.com/go-chi/chi v1.5.4/go.mod h1:uaf8YgoFazUOkPBG7fxPftUylNumIev9awIWOENIuEg=
326-
github.com/go-chi/chi/v5 v5.0.1 h1:ALxjCrTf1aflOlkhMnCUP86MubbWFrzB3gkRPReLpTo=
327326
github.com/go-chi/chi/v5 v5.0.1/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
327+
github.com/go-chi/chi/v5 v5.0.4 h1:5e494iHzsYBiyXQAHHuI4tyJS9M3V84OuX3ufIIGHFo=
328+
github.com/go-chi/chi/v5 v5.0.4/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
328329
github.com/go-chi/cors v1.2.0 h1:tV1g1XENQ8ku4Bq3K9ub2AtgG+p16SmzeMSGTwrOKdE=
329330
github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
330331
github.com/go-enry/go-enry/v2 v2.7.1 h1:WCqtfyteIz61GYk9lRVy8HblvIv4cP9GIiwm/6txCbU=
@@ -491,6 +492,7 @@ github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/V
491492
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
492493
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
493494
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
495+
github.com/goccy/go-json v0.4.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
494496
github.com/goccy/go-json v0.7.4 h1:B44qRUFwz/vxPKPISQ1KhvzRi9kZ28RAf6YtjriBZ5k=
495497
github.com/goccy/go-json v0.7.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
496498
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=

models/db/context.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ type Context struct {
3131
e Engine
3232
}
3333

34+
// WithEngine returns a db.Context from a context.Context and db.Engine
35+
func WithEngine(ctx context.Context, e Engine) *Context {
36+
return &Context{
37+
Context: ctx,
38+
e: e,
39+
}
40+
}
41+
3442
// Engine returns db engine
3543
func (ctx *Context) Engine() Engine {
3644
return ctx.e

models/repo.go

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,16 +1146,6 @@ func CreateRepository(ctx context.Context, doer, u *User, repo *Repository, over
11461146
return fmt.Errorf("recalculateAccesses: %v", err)
11471147
}
11481148

1149-
if u.Visibility == api.VisibleTypePublic && !repo.IsPrivate {
1150-
// Create/Remove git-daemon-export-ok for git-daemon...
1151-
daemonExportFile := path.Join(repo.RepoPath(), `git-daemon-export-ok`)
1152-
if f, err := os.Create(daemonExportFile); err != nil {
1153-
log.Error("Failed to create %s: %v", daemonExportFile, err)
1154-
} else {
1155-
f.Close()
1156-
}
1157-
}
1158-
11591149
if setting.Service.AutoWatchNewRepos {
11601150
if err = watchRepo(db.GetEngine(ctx), doer.ID, repo.ID, true); err != nil {
11611151
return fmt.Errorf("watchRepo: %v", err)
@@ -1169,6 +1159,38 @@ func CreateRepository(ctx context.Context, doer, u *User, repo *Repository, over
11691159
return nil
11701160
}
11711161

1162+
// CheckDaemonExportOK creates/removes git-daemon-export-ok for git-daemon...
1163+
func (repo *Repository) CheckDaemonExportOK(ctx context.Context) error {
1164+
e := db.GetEngine(ctx)
1165+
if err := repo.getOwner(e); err != nil {
1166+
return err
1167+
}
1168+
1169+
// Create/Remove git-daemon-export-ok for git-daemon...
1170+
daemonExportFile := path.Join(repo.RepoPath(), `git-daemon-export-ok`)
1171+
1172+
isExist, err := util.IsExist(daemonExportFile)
1173+
if err != nil {
1174+
log.Error("Unable to check if %s exists. Error: %v", daemonExportFile, err)
1175+
return err
1176+
}
1177+
1178+
isPublic := !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePublic
1179+
if !isPublic && isExist {
1180+
if err = util.Remove(daemonExportFile); err != nil {
1181+
log.Error("Failed to remove %s: %v", daemonExportFile, err)
1182+
}
1183+
} else if isPublic && !isExist {
1184+
if f, err := os.Create(daemonExportFile); err != nil {
1185+
log.Error("Failed to create %s: %v", daemonExportFile, err)
1186+
} else {
1187+
f.Close()
1188+
}
1189+
}
1190+
1191+
return nil
1192+
}
1193+
11721194
func countRepositories(userID int64, private bool) int64 {
11731195
sess := db.GetEngine(db.DefaultContext).Where("id > 0")
11741196

@@ -1318,24 +1340,9 @@ func updateRepository(e db.Engine, repo *Repository, visibilityChanged bool) (er
13181340
}
13191341

13201342
// Create/Remove git-daemon-export-ok for git-daemon...
1321-
daemonExportFile := path.Join(repo.RepoPath(), `git-daemon-export-ok`)
1322-
isExist, err := util.IsExist(daemonExportFile)
1323-
isPublic := !repo.IsPrivate && repo.Owner.Visibility == api.VisibleTypePublic
1324-
if err != nil {
1325-
log.Error("Unable to check if %s exists. Error: %v", daemonExportFile, err)
1343+
if err := repo.CheckDaemonExportOK(db.WithEngine(db.DefaultContext, e)); err != nil {
13261344
return err
13271345
}
1328-
if !isPublic && isExist {
1329-
if err = util.Remove(daemonExportFile); err != nil {
1330-
log.Error("Failed to remove %s: %v", daemonExportFile, err)
1331-
}
1332-
} else if isPublic && !isExist {
1333-
if f, err := os.Create(daemonExportFile); err != nil {
1334-
log.Error("Failed to create %s: %v", daemonExportFile, err)
1335-
} else {
1336-
f.Close()
1337-
}
1338-
}
13391346

13401347
forkRepos, err := getRepositoriesByForkID(e, repo.ID)
13411348
if err != nil {

modules/context/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333

3434
"gitea.com/go-chi/cache"
3535
"gitea.com/go-chi/session"
36-
"github.com/go-chi/chi"
36+
chi "github.com/go-chi/chi/v5"
3737
"github.com/unknwon/com"
3838
"github.com/unknwon/i18n"
3939
"github.com/unrolled/render"

modules/git/git.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ func Init(ctx context.Context) error {
204204
return err
205205
}
206206
}
207+
if setting.Git.DisableCoreProtectNTFS {
208+
if err := checkAndSetConfig("core.protectntfs", "false", true); err != nil {
209+
return err
210+
}
211+
GlobalCommandArgs = append(GlobalCommandArgs, "-c", "core.protectntfs=false")
212+
}
207213
return nil
208214
}
209215

modules/repository/adopt.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ func AdoptRepository(doer, u *models.User, opts models.CreateRepoOptions) (*mode
6868
if err := adoptRepository(ctx, repoPath, doer, repo, opts); err != nil {
6969
return fmt.Errorf("createDelegateHooks: %v", err)
7070
}
71+
if err := repo.CheckDaemonExportOK(ctx); err != nil {
72+
return fmt.Errorf("checkDaemonExportOK: %v", err)
73+
}
7174

7275
// Initialize Issue Labels if selected
7376
if len(opts.IssueLabels) > 0 {

modules/repository/create.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ func CreateRepository(doer, u *models.User, opts models.CreateRepoOptions) (*mod
105105
}
106106
}
107107

108-
if stdout, err := git.NewCommand("update-server-info").
108+
if err := repo.CheckDaemonExportOK(ctx); err != nil {
109+
return fmt.Errorf("checkDaemonExportOK: %v", err)
110+
}
111+
112+
if stdout, err := git.NewCommandContext(ctx, "update-server-info").
109113
SetDescription(fmt.Sprintf("CreateRepository(git update-server-info): %s", repoPath)).
110114
RunInDir(repoPath); err != nil {
111115
log.Error("CreateRepository(git update-server-info) in %v: Stdout: %s\nError: %v", repo, stdout, err)

0 commit comments

Comments
 (0)