From ee63dd85bb5118cc18a4671bac4da80359e5928d Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 18 Aug 2022 10:02:28 +0800 Subject: [PATCH 1/3] Fix owners cannot create organization repos bug --- routers/web/org/teams.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index 284fb096f3405..9ee66a1a3e86c 100644 --- a/routers/web/org/teams.go +++ b/routers/web/org/teams.go @@ -416,7 +416,11 @@ func EditTeamPost(ctx *context.Context) { isIncludeAllChanged = true t.IncludesAllRepositories = includesAllRepositories } + t.CanCreateOrgRepo = form.CanCreateOrgRepo + } else { + t.CanCreateOrgRepo = true } + t.Description = form.Description if t.AccessMode < perm.AccessModeAdmin { units := make([]organization.TeamUnit, 0, len(unitPerms)) @@ -433,7 +437,6 @@ func EditTeamPost(ctx *context.Context) { return } } - t.CanCreateOrgRepo = form.CanCreateOrgRepo if ctx.HasError() { ctx.HTML(http.StatusOK, tplTeamNew) From 79e59dfd8e22f37408aedd5c6afa6933aabfb01f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 18 Aug 2022 10:05:53 +0800 Subject: [PATCH 2/3] Fix api --- routers/api/v1/org/team.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index f8c37303d6759..0f3f49390400c 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -262,7 +262,11 @@ func EditTeam(ctx *context.APIContext) { } if form.CanCreateOrgRepo != nil { - team.CanCreateOrgRepo = *form.CanCreateOrgRepo + if team.IsOwnerTeam() { + team.CanCreateOrgRepo = true + } else { + team.CanCreateOrgRepo = *form.CanCreateOrgRepo + } } if len(form.Name) > 0 { From e586cd5e81b31170729c0cda4381743b5efe0f33 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 18 Aug 2022 10:23:27 +0800 Subject: [PATCH 3/3] Update routers/api/v1/org/team.go Co-authored-by: Gusted --- routers/api/v1/org/team.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index 0f3f49390400c..db37bac57ec49 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -262,11 +262,7 @@ func EditTeam(ctx *context.APIContext) { } if form.CanCreateOrgRepo != nil { - if team.IsOwnerTeam() { - team.CanCreateOrgRepo = true - } else { - team.CanCreateOrgRepo = *form.CanCreateOrgRepo - } + team.CanCreateOrgRepo = team.IsOwnerTeam() || *form.CanCreateOrgRepo } if len(form.Name) > 0 {