1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Support default private when creating or migrating repository (#3239)

* support default private when creating or migrating repository

* fix fmt

* use string constants on repository default private in app.ini

* fix fmt
This commit is contained in:
Lunny Xiao
2017-12-20 06:59:56 -06:00
committed by GitHub
parent e67b4055f9
commit 529482135c
5 changed files with 28 additions and 2 deletions

View File

@@ -81,6 +81,19 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
return org
}
func getRepoPrivate(ctx *context.Context) bool {
switch strings.ToLower(setting.Repository.DefaultPrivate) {
case setting.RepoCreatingLastUserVisibility:
return ctx.User.LastRepoVisibility
case setting.RepoCreatingPrivate:
return true
case setting.RepoCreatingPublic:
return false
default:
return ctx.User.LastRepoVisibility
}
}
// Create render creating repository page
func Create(ctx *context.Context) {
if !ctx.User.CanCreateRepo() {
@@ -94,7 +107,7 @@ func Create(ctx *context.Context) {
ctx.Data["Licenses"] = models.Licenses
ctx.Data["Readmes"] = models.Readmes
ctx.Data["readme"] = "Default"
ctx.Data["private"] = ctx.User.LastRepoVisibility
ctx.Data["private"] = getRepoPrivate(ctx)
ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
ctxUser := checkContextUser(ctx, ctx.QueryInt64("org"))
@@ -170,7 +183,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
// Migrate render migration of repository page
func Migrate(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("new_migrate")
ctx.Data["private"] = ctx.User.LastRepoVisibility
ctx.Data["private"] = getRepoPrivate(ctx)
ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
ctx.Data["mirror"] = ctx.Query("mirror") == "1"
ctx.Data["LFSActive"] = setting.LFS.StartServer