Skip to content

Commit 350d70e

Browse files
committed
add comments
1 parent b997b21 commit 350d70e

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

models/organization/team_repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func RemoveTeamRepo(ctx context.Context, teamID, repoID int64) error {
5252

5353
// GetTeamsWithAccessToAnyRepoUnit returns all teams in an organization that have given access level to the repository special unit.
5454
// This function is only used for finding some teams that can be used as branch protection allowlist or reviewers, it isn't really used for access control.
55+
// FIXME: TEAM-UNIT-PERMISSION this logic is not complete, search the fixme keyword to see more details
5556
func GetTeamsWithAccessToAnyRepoUnit(ctx context.Context, orgID, repoID int64, mode perm.AccessMode, unitType unit.Type, unitTypesMore ...unit.Type) ([]*Team, error) {
5657
teams := make([]*Team, 0, 5)
5758

routers/web/org/teams.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,22 @@ func NewTeam(ctx *context.Context) {
283283
}
284284

285285
// FIXME: TEAM-UNIT-PERMISSION: this design is not right, when a new unit is added in the future,
286-
// admin team won't inherit the correct admin permission for the new unit.
286+
// The existing teams won't inherit the correct admin permission for the new unit.
287+
// The full history is like this:
288+
// 1. There was only "team", no "team unit", so "team.authorize" was used to determine the team permission.
289+
// 2. Later, "team unit" was introduced, then the usage of "team.authorize" became inconsistent, and causes various bugs.
290+
// - Sometimes, "team.authorize" is used to determine the team permission, e.g. admin, owner
291+
// - Sometimes, "team unit" is used not really used and "team unit" is used.
292+
// - Some functions like `GetTeamsWithAccessToAnyRepoUnit` use both.
293+
//
294+
// 3. After introducing "team unit" and more unclear changes, it becomes difficult to maintain team permissions.
295+
// - Org owner need to click the permission for each unit, but can't just set a common "write" permission for all units.
296+
//
297+
// Ideally, "team.authorize=write" should mean the team has write access to all units including newly (future) added ones.
287298
func getUnitPerms(forms url.Values, teamPermission perm.AccessMode) map[unit_model.Type]perm.AccessMode {
288299
unitPerms := make(map[unit_model.Type]perm.AccessMode)
289300
for _, ut := range unit_model.AllRepoUnitTypes {
290-
// Default accessmode is none
301+
// Default access mode is none
291302
unitPerms[ut] = perm.AccessModeNone
292303

293304
v, ok := forms[fmt.Sprintf("unit_%d", ut)]

templates/repo/settings/collaboration.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
{{.Name}}
6464
</a>
6565
<div class="flex-item-body flex-text-block">
66+
{{/*FIXME: TEAM-UNIT-PERMISSION this display is not right, search the fixme keyword to see more details */}}
6667
{{svg "octicon-shield-lock"}}
6768
{{if eq .AccessMode 0}}
6869
{{ctx.Locale.Tr "repo.settings.collaboration.per_unit"}}

0 commit comments

Comments
 (0)