Skip to content

gitlab import doesn't ignore archived subgroups #579

Open

Description

@aschleifer

When you archive a subgroup but still sync the parent group as it has some other repositories next to the archived subgroup, then the archived subgroup still shows up in a config file with an empty object {} as value.

In my opinion the vcspull import gitlab command should ignore archived groups the same as it ignores archived repositories.

Activity

  1. tony commented on Nov 28, 2026

    @tony
    Member

    Root cause

    Two separate behaviors combine to produce #579 on v1.69.0 (c113032):

    1. Pruning removes stale entries inside a subgroup section without removing the emptied workspace key (src/vcspull/cli/import_cmd/_common.py, src/vcspull/cli/import_cmd/_common.py):

      • In --mode org without --flatten-groups, each GitLab subgroup maps to its own workspace root key in raw_config (for example ./parent/archived-sub:).
      • When that subgroup is archived and the parent group is re-synced with --sync or --prune, _run_import() deletes each stale repo entry via del ws_entries[repo_name] while leaving the outer ws_label key in raw_config, writing "./parent/archived-sub": {} back to YAML/JSON.
      • Dropping raw_config[ws_label] should be gated on ws_entries becoming empty because at least one entry in that section was pruned during the run (preserving any unrelated empty workspace sections a user already had in the file).
    2. GitLab group-level archiving vs. project-level archived=false (src/vcspull/_internal/remotes/gitlab.py, src/vcspull/_internal/remotes/gitlab.py):

      • GitLabImporter._fetch_group() calls GET /groups/{target}/projects with include_subgroups=true and, when --archived is not passed, archived=false.
      • In GitLab's Groups REST API, archiving a group or subgroup (POST /groups/:id/archive) marks the namespace read-only/archived at the group level without flipping project-level archived: true on child projects; archived=false only checks project-level archived, whereas active=true (added in GitLab 18.8 on GET /groups/:id/projects and GET /groups/:id/descendant_groups) excludes projects whose group or ancestor subgroup is archived or marked for deletion.
      • Passing active=true alongside archived=false when not options.include_archived (and verifying fallback behavior on self-hosted GitLab < 18.8, e.g. checking /groups/{target}/descendant_groups if active is ignored) prevents fresh imports from pulling projects out of archived subgroups as well.

    Related PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions