Skip to content

Commit 4bbf36e

Browse files
authored
Merge pull request #1 from lafrenierejm/branch-protection-drift
feat: Reduce number of iterations over `actors`
2 parents 0a15a36 + a52abfa commit 4bbf36e

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

github/util_v4_branch_protection.go

+4-20
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,10 @@ func setPushActorIDs(actors []PushActorTypes, data BranchProtectionResourceData,
475475
id = a.Actor.User.ID.(string)
476476
} else if a.Actor.App.ID != nil {
477477
id = a.Actor.App.ID.(string)
478+
} else if a.Actor.Team.Slug != "" {
479+
formattedID = orgName + "/" + string(a.Actor.Team.Slug)
480+
} else if a.Actor.User.Login != "" {
481+
formattedID = "/" + string(a.Actor.User.Login)
478482
}
479483

480484
if id != "" {
@@ -485,26 +489,6 @@ func setPushActorIDs(actors []PushActorTypes, data BranchProtectionResourceData,
485489
}
486490
}
487491

488-
for _, a := range actors {
489-
if a.Actor.Team.ID == nil && a.Actor.User.ID == nil && a.Actor.App.ID == nil {
490-
var formattedID string
491-
if a.Actor.Team.Slug != "" {
492-
formattedID = orgName + "/" + string(a.Actor.Team.Slug)
493-
} else if a.Actor.User.Login != "" {
494-
formattedID = "/" + string(a.Actor.User.Login)
495-
} else if a.Actor.App != (Actor{}) {
496-
continue
497-
}
498-
499-
if formattedID != "" {
500-
if _, exists := seenIDs[formattedID]; !exists {
501-
pushActors = append(pushActors, formattedID)
502-
seenIDs[formattedID] = struct{}{}
503-
}
504-
}
505-
}
506-
}
507-
508492
// Sort for consistent ordering
509493
sort.Strings(pushActors)
510494

0 commit comments

Comments
 (0)