Skip to content

install: handle git submodule (gitlink) sources instead of installing empty directories #433

Closed

Description

@runkids

Problem

Split from #239 (§1). skillshare install never resolves git submodules. When a hub repo mounts an upstream skill as a submodule (gitlink, mode 160000), the result depends on how the source is written, and one case succeeds silently with nothing in it:

Source What happens today
Whole hub (discovery) Shallow clone leaves the gitlink as an empty dir; discoverSkills finds no SKILL.md there, so the submodule's skills silently disappear from the picker
Subdir = the gitlink itself Sparse checkout succeeds with an empty directory; os.Stat passes, copyDir copies nothing, checkSkillFile only appends the warning no SKILL.md found in skill directory — install reports success
Subdir inside the submodule subdirectory missing after checkout → API fallback → full clone → subdirectory '...' does not exist in repository
--track hub Clone succeeds, gitlink stays empty, later git pull never updates it

The Contents API fallbacks do not help: GitHub only handles dir/file, Gitea skips other types, CNB explicitly ignores submodule entries.

Evidence (v0.25.0, aeaea40e)

  • No --recurse-submodules / submodule update anywhere under internal/install
  • internal/install/install_apply.go:518-522 sparse fast path, :641-645 warn-only checkSkillFile
  • internal/install/sparse_checkout.go:46-69
  • internal/install/gitea_download.go:399-400 ("Ignore links and submodules")
  • website/docs/how-to/advanced/migration.md only covers migrating from submodules, not hub authors using them

Proposal

Phase 1 (S) — detect and fail loudly. After checkout, run git ls-tree -r -d HEAD and check whether the requested path is a gitlink or sits under one. If so, return an explicit error naming the submodule path, its upstream URL (from .gitmodules) and pinned commit, and suggest installing the upstream directly or vendoring it into the hub. During whole-repo discovery, warn for each gitlink skipped. Document the limitation in install.md.

Phase 2 (M) — scoped resolution for non-tracked install/update. Run git submodule update --init --depth 1 -- <path> only for gitlinks that intersect the requested path, fall back to a full fetch when the server refuses a depth-1 fetch of a pinned SHA, no --recursive, reuse the existing same-host insteadOf auth env. Verified with plain git that this works inside a sparse checkout for all three path shapes above.

Not in scope

  • Tracked repos and cross-host private sub-repo auth (later phase)
  • A vendor sync / lockfile command — git subtree or CI already covers it on the hub side
  • Reading .gitmodules and re-entering the install flow with the sub-URL (alternative; revisit only if cross-host auth or large upstreams become a real need)

Open questions before Phase 2

  1. Real-host behaviour of --filter=blob:none + shallow submodule fetch of a pinned SHA (GitHub / GitLab / Gitea)
  2. GitHub Contents API response for a submodule entry (assumed type: file without download_url, unverified)
  3. Whether metadata source for a skill inside a submodule records the hub path or the upstream path (tree_hash is empty for paths inside a submodule, so update must compare commits)
  4. Minimum git version gate (≥ 2.45.1, CVE-2024-32002)
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

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions