Skip to content

add/discover: detect shallow clones and persist depth to config #550

@tony

Description

@tony

Summary

vcspull discover (and add) record only the repo: URL for each checkout. They don't detect whether a local clone is shallow, and the config schema has no way to express shallow/depth — so a subsequent vcspull sync performs/keeps a full clone. For workspaces holding 100+ repos, full clones are a significant disk and time cost.

Current behavior (v1.60.1)

  • discover writes a minimal {repo: <url>} entry per repo (see discover_repos in src/vcspull/cli/discover.py); add does the same (src/vcspull/cli/add.py).
  • The per-repo schema RepoEntryDict exposes only repo and options (src/vcspull/types.py) — there is no shallow/depth key, so shallow state can't be represented at all.
  • Neither command runs anything like git rev-parse --is-shallow-repository, so an existing shallow checkout is silently recorded as if it were full.

The backend already supports it (libvcs v0.41.0)

  • GitSync(git_shallow=True)git clone --depth 1 (see GitSync.obtain in src/libvcs/sync/git.py).
  • Git.clone(depth=…, shallow_since=…, shallow_exclude=…) and Git.fetch(unshallow=…, depth=…) are all exposed (src/libvcs/cmd/git.py).

The capability exists in the backend; vcspull just never plumbs it through to config or sync.

Proposal

  1. On discover/add, detect shallow checkouts via git rev-parse --is-shallow-repository and record the result (e.g. shallow: true, or depth: <n>).
  2. Add a shallow (bool) and/or depth (int) key to the per-repo schema, plumbed to GitSync(git_shallow=…) on sync.
  3. Optional --shallow / --depth N flag on discover/add to force shallow regardless of the on-disk state.

Happy to help test against a large multi-repo config.

Metadata

Metadata

Assignees

No one assigned

    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