Skip to content

Commit

Permalink
include and exclude gitlab subgroups (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperspencer authored Aug 27, 2024
1 parent 3cd914a commit d51caa0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,34 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
excludeorgs := types.GetMap(repo.ExcludeOrgs)
languages := types.GetMap(repo.Filter.Languages)

for _, org := range repo.IncludeOrgs {
group, _, err := client.Groups.GetGroup(org, &gitlab.GetGroupOptions{})
if err != nil {
sub.Error().
Msg(err.Error())
continue
}
subgroups, _, err := client.Groups.ListSubGroups(group.ID, &gitlab.ListSubGroupsOptions{})
for _, sub := range subgroups {
includeorgs[sub.FullPath] = true
}
}

fmt.Println(includeorgs)

for _, org := range repo.ExcludeOrgs {
group, _, err := client.Groups.GetGroup(org, &gitlab.GetGroupOptions{})
if err != nil {
sub.Error().
Msg(err.Error())
continue
}
subgroups, _, err := client.Groups.ListSubGroups(group.ID, &gitlab.ListSubGroupsOptions{})
for _, sub := range subgroups {
excludeorgs[sub.FullPath] = true
}
}

for _, r := range gitlabrepos {
if repo.Filter.ExcludeForks {
if r.ForkedFromProject != nil {
Expand Down Expand Up @@ -442,6 +470,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
if excludeorgs[r.Namespace.FullPath] {
continue
}

if len(include) == 0 {
if len(includeorgs) == 0 || includeorgs[r.Namespace.FullPath] {
if r.RepositoryAccessLevel != gitlab.DisabledAccessControl {
Expand Down

0 comments on commit d51caa0

Please sign in to comment.