From 2c7b0f770523217cf76eeb7fd4d954e8b436f571 Mon Sep 17 00:00:00 2001 From: Mick Grove Date: Fri, 8 Aug 2025 18:08:17 -0700 Subject: [PATCH] GitLab: include nested subgroup projects when enumerating group repositories --- src/gitlab.rs | 44 +++++++------------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/src/gitlab.rs b/src/gitlab.rs index c0a85e2..c7b0549 100644 --- a/src/gitlab.rs +++ b/src/gitlab.rs @@ -88,27 +88,9 @@ pub async fn enumerate_repo_urls( hits.into_iter().next().context(format!("GitLab user `{}` not found", username))?; let user_id = user.id; - // b) List that user's projects applying the requested filter - let mut builder = UserProjects::builder(); - builder.user(user_id); - - match repo_specifiers.repo_filter { - RepoType::Owner => { - builder.owned(true); - } - RepoType::Member => { - builder.membership(true); - } - RepoType::All => { - // this doesn’t set any owned() or membership() flags on the builder, which in GitLab’s API defaults to "all visible repos" - } - } - - // Extract the builder to a separate variable to avoid borrowing a temporary, - // allowing us to modify its fields before building the endpoint. - let projects_ep = builder.build()?; + // b) List that user’s projects by ID + let projects_ep = UserProjects::builder().user(user_id).build()?; let projects: Vec = projects_ep.query(&client)?; - for proj in projects { repo_urls.push(proj.http_url_to_repo); } @@ -120,31 +102,19 @@ pub async fn enumerate_repo_urls( // all groups let groups: Vec = if repo_specifiers.all_groups { - gitlab::api::groups::Groups::builder() - .all_available(true) - .build()? - .query(&client.clone())? + gitlab::api::groups::Groups::builder().build()?.query(&client.clone())? } else { let mut found: Vec = Vec::new(); for grp in &repo_specifiers.group { - let ep = gitlab::api::groups::Group::builder().group(grp).build()?; - let group: SimpleGroup = ep.query(&client.clone())?; - found.push(group); + let ep = gitlab::api::groups::Groups::builder().search(grp).build()?; + let page: Vec = ep.query(&client.clone())?; + found.extend(page); } found }; for group in groups { - let mut gp_builder = GroupProjects::builder(); - gp_builder.group(group.id); - // Ensure projects from nested subgroups are also enumerated - gp_builder.include_subgroups(true); - - if matches!(repo_specifiers.repo_filter, RepoType::Owner) { - gp_builder.owned(true); - } - - let gp_ep = gp_builder.build()?; + let gp_ep = GroupProjects::builder().group(group.id).build()?; let projects: Vec = gp_ep.query(&client)?; for proj in projects { repo_urls.push(proj.http_url_to_repo);