Skip to content

Commit fe135f3

Browse files
committed
fix comment
1 parent c935ddd commit fe135f3

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

models/organization/team.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff 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

models/perm/access/repo_permission.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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

705709
func CanDoerManageOrgRepoCollaboratorTeam(ctx context.Context, repo *repo_model.Repository, perm *Permission) bool {

models/user/user.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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 ''"`

0 commit comments

Comments
 (0)