mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +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:
parent
e67b4055f9
commit
529482135c
5 changed files with 28 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue