You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-11-23 21:44:44 +02:00
Enforce exact matching for GitLab groups (#4473)
This commit is contained in:
@@ -749,7 +749,7 @@ func (g *GitLab) Org(ctx context.Context, u *model.User, owner string) (*model.O
|
||||
groups, _, err := client.Groups.ListGroups(&gitlab.ListGroupsOptions{
|
||||
ListOptions: gitlab.ListOptions{
|
||||
Page: 1,
|
||||
PerPage: 1,
|
||||
PerPage: perPage,
|
||||
},
|
||||
Search: gitlab.Ptr(owner),
|
||||
}, gitlab.WithContext(ctx))
|
||||
@@ -757,13 +757,21 @@ func (g *GitLab) Org(ctx context.Context, u *model.User, owner string) (*model.O
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(groups) != 1 {
|
||||
var matchedGroup *gitlab.Group
|
||||
for _, group := range groups {
|
||||
if group.FullPath == owner {
|
||||
matchedGroup = group
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if matchedGroup == nil {
|
||||
return nil, fmt.Errorf("could not find org %s", owner)
|
||||
}
|
||||
|
||||
return &model.Org{
|
||||
Name: groups[0].FullPath,
|
||||
Private: groups[0].Visibility != gitlab.PublicVisibility,
|
||||
Name: matchedGroup.FullPath,
|
||||
Private: matchedGroup.Visibility != gitlab.PublicVisibility,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user