Skip to content

Always clone submodules for new source resolvers #1210

Description

@smoparth

Context

The design proposal (docs/proposals/new-resolver-config.md) states under "git clone":

Like pip's VCS feature, all git clone operations automatically retrieve all submodules recursively.

And under "Deprecations":

git_options.submodules is not needed. Like pip, Fromager will always clone all submodules.

Parent epic: #936
Parent issue: #1048

Problem

Currently download_git_source() in sources.py reads git_opts.submodules and git_opts.submodule_paths to decide whether to clone submodules:

submodules: bool | list[str] = False
if git_opts.submodule_paths:
    submodules = git_opts.submodule_paths
elif git_opts.submodules:
    submodules = True

This logic applies to all git clones, including those triggered by the new source config. Since submodules defaults to False, no submodules are cloned even when a new source resolver triggers the git clone.

For example, a package configured as:
source:
provider: gitlab-tag-git
project_url: https://gitlab.example/org/project
Would clone without submodules, even though the proposal says it should always clone them (like pip does).

Fix
When the git clone is triggered by a new source resolver (not req.url), always pass submodules=True to gitutils.git_clone() regardless of git_options.submodules. The old git_options.submodules field should only apply to legacy req.url flows.

One approach is to pass a flag to download_git_source() indicating the clone was triggered by a source resolver. Another is to check pbi.source_resolver inside the function.

Consider using gitutils.git_clone_fast() for source-resolver-triggered clones, since it already handles submodules automatically and uses efficient blobless cloning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions