File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,8 +92,6 @@ type Team struct {
9292 // And the user will become the repo's admin (via collaborator) after the creation.
9393 CanCreateOrgRepo bool `xorm:"NOT NULL DEFAULT false"`
9494
95- // FIXME: ORG-REPO-ADMIN-DANGER-ZONE: it needs a new field to decide whether a repo admin can manage the repo's danger zone
96-
9795 Visibility structs.VisibleType `xorm:"NOT NULL DEFAULT 2"`
9896}
9997
Original file line number Diff line number Diff line change @@ -693,13 +693,17 @@ func CanDoerManageRepoDangerZone(perm *Permission) bool {
693693 }
694694
695695 // FIXME: ORG-REPO-ADMIN-DANGER-ZONE: this is the legacy logic, "org repo admin" can delete a repo
696- // Ideally we need a new field in the Team like "CanAdminManageDangerZone " to control this permission, but for now we keep the legacy logic
696+ // Ideally we need a new field in like "AdminManageDangerZone " to control this permission, but for now we keep the legacy logic
697697 for _ , team := range perm .orgRepoTeams {
698698 if team .AccessMode >= perm_model .AccessModeAdmin {
699699 return true
700700 }
701701 }
702- return false
702+ // A special case: if the team allows to create repo, then the doer will be added as a collaborator with admin access.
703+ // For this case, we also allow the doer to manage the danger zone as well, because the doer is effectively a repo admin.
704+ // Since the admin permission from team is already allowed above (legacy logic), here nothing worse.
705+ // Keep in mind: the newly created repo isn't in any org team, it only has the doer as a collaborator with admin access.
706+ return perm .IsAdmin ()
703707}
704708
705709func CanDoerManageOrgRepoCollaboratorTeam (ctx context.Context , repo * repo_model.Repository , perm * Permission ) bool {
Original file line number Diff line number Diff line change @@ -150,9 +150,11 @@ type User struct {
150150
151151 // Introduced by "Add teams to repo on collaboration page. (#8045)"
152152 // Whether a repo admin can add/remove a team to/from the repo on the collaboration page
153- // Although this should be a team setting .....
154153 RepoAdminChangeTeamAccess bool `xorm:"NOT NULL DEFAULT false"`
155154
155+ // FIXME: ORG-REPO-ADMIN-DANGER-ZONE: it needs a new field to decide whether a repo admin can manage the repo's danger zone
156+ // Team won't work for this case, because a newly create org repo isn't in any team (same as above)
157+
156158 // Preferences
157159 DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"`
158160 Theme string `xorm:"NOT NULL DEFAULT ''"`
You can’t perform that action at this time.
0 commit comments