Skip to content

feat: add depth option to clone/fetch for shallow clones#30

Open
mizchi wants to merge 1 commit intomainfrom
feat/clone-depth
Open

feat: add depth option to clone/fetch for shallow clones#30
mizchi wants to merge 1 commit intomainfrom
feat/clone-depth

Conversation

@mizchi
Copy link
Copy Markdown
Member

@mizchi mizchi commented Mar 31, 2026

Summary

  • Expose existing protocol-level deepen support to the JavaScript API
  • Add depth?: number to BitCloneOptions and BitFetchOptions
  • When depth is 0 (default), full clone behavior is preserved
  • When depth > 0, the server returns only the specified number of commits

Changes

  • src/lib/js_api_exports.mbt: Add depth : Int parameter to js_clone_remote, js_fetch_remote, and their promise wrappers
  • npm/lib.js: Pass options.depth ?? 0 to raw clone/fetch calls
  • npm/lib.d.ts: Add depth?: number to option interfaces

Usage

import { clone, createFetchTransport } from "@mizchi/bit";

// Full clone (default, depth=0)
await clone(backend, "/repo", url, transport);

// Shallow clone (depth=1)
await clone(backend, "/repo", url, transport, { depth: 1 });

Test plan

  • Full clone still works (depth=0, default)
  • Shallow clone with depth=1 returns single commit
  • Fetch with depth works similarly

🤖 Generated with Claude Code

Expose the existing protocol-level deepen support to the JavaScript API.
The depth parameter is passed through to fetch_pack_with_http which
encodes it as "deepen {depth}" in the git smart HTTP protocol.

When depth is 0 (default), full clone behavior is preserved.
When depth > 0, the server returns only the specified number of commits.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant