From 35ca651c803a859900f9b7e76b02c0becdacf47e Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 18 Aug 2022 19:54:48 +0100 Subject: [PATCH] Fix owners cannot create organization repos bug (#20841) (#20854) Backport #20841 * Fix owners cannot create organization repos bug * Fix api * Update routers/api/v1/org/team.go Co-authored-by: Gusted Co-authored-by: Lunny Xiao Co-authored-by: Gusted Co-authored-by: John Olheiser --- routers/api/v1/org/team.go | 2 +- routers/web/org/teams.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index f8c37303d..db37bac57 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -262,7 +262,7 @@ func EditTeam(ctx *context.APIContext) { } if form.CanCreateOrgRepo != nil { - team.CanCreateOrgRepo = *form.CanCreateOrgRepo + team.CanCreateOrgRepo = team.IsOwnerTeam() || *form.CanCreateOrgRepo } if len(form.Name) > 0 { diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index 284fb096f..9ee66a1a3 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)