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:
@@ -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
|
||||
|
Reference in New Issue
Block a user