diff options
author | Unknwon <u@gogs.io> | 2015-10-25 04:26:26 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-10-25 04:26:26 -0400 |
commit | 022820103d622dda74aa1c619ca46838a14b762a (patch) | |
tree | 2de093f709bb04c366cee4ebb73dcc3230f7019a /routers/repo/repo.go | |
parent | d5fab7f1b993ac389d751bfb87774549c4f3f4c2 (diff) | |
download | gitea-022820103d622dda74aa1c619ca46838a14b762a.tar.gz gitea-022820103d622dda74aa1c619ca46838a14b762a.zip |
#1657 allow forcing all private repos
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r-- | routers/repo/repo.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 8a0c5f975c..f7e7e32093 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -46,7 +46,7 @@ func checkContextUser(ctx *middleware.Context, uid int64) *models.User { } if err != nil { - ctx.Handle(500, "checkContextUser", fmt.Errorf("GetUserById(%d): %v", uid, err)) + ctx.Handle(500, "GetUserByID", fmt.Errorf("[%d]: %v", uid, err)) return nil } @@ -67,6 +67,7 @@ func Create(ctx *middleware.Context) { ctx.Data["Readmes"] = models.Readmes ctx.Data["readme"] = "Default" ctx.Data["private"] = ctx.User.LastRepoVisibility + ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate ctxUser := checkContextUser(ctx, ctx.QueryInt64("org")) if ctx.Written() { @@ -117,11 +118,11 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) { Gitignores: form.Gitignores, License: form.License, Readme: form.Readme, - IsPrivate: form.Private, + IsPrivate: form.Private || setting.Repository.ForcePrivate, AutoInit: form.AutoInit, }) if err == nil { - log.Trace("Repository created: %s/%s", ctxUser.Name, repo.Name) + log.Trace("Repository created[%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name) ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name) return } @@ -138,6 +139,7 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) { func Migrate(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Tr("new_migrate") ctx.Data["private"] = ctx.User.LastRepoVisibility + ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate ctxUser := checkContextUser(ctx, ctx.QueryInt64("org")) if ctx.Written() { @@ -185,9 +187,15 @@ func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) { return } - repo, err := models.MigrateRepository(ctxUser, form.RepoName, form.Description, form.Private, form.Mirror, remoteAddr) + repo, err := models.MigrateRepository(ctxUser, models.MigrateRepoOptions{ + Name: form.RepoName, + Description: form.Description, + IsPrivate: form.Private || setting.Repository.ForcePrivate, + IsMirror: form.Mirror, + RemoteAddr: remoteAddr, + }) if err == nil { - log.Trace("Repository migrated: %s/%s", ctxUser.Name, form.RepoName) + log.Trace("Repository migrated[%d]: %s/%s", repo.ID, ctxUser.Name, form.RepoName) ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + form.RepoName) return } |