feat(clone): add wt clone with category-based placement - #122
Open
brosu wants to merge 2 commits into
Open
Conversation
Introduce `wt clone <category> <owner/repo|url> [dest]`: acquire a repo's canonical checkout under a category's repo_root in a host/owner/repo layout, left on its default branch and ready to inspect. Fills wt's missing front half — every other command assumes the repo already exists locally. Adds the `categories` config concept (repo_root + gh_auth / git_protocol / glab_host) that drives placement and auth. owner/repo is resolved to a clone URL via gh/glab honoring git_protocol; a full URL is used as-is. - cmd/clone.go: command, URL resolution, gh auth switch, placement, hooks - cmd/category.go: Category type, builtins, resolve/merge, repoPlacementPath - cmd/config.go: [categories.*], default_category, repo_pattern, clone hooks - README/llms.txt/examples + unit tests + e2e scenarios Default repo_pattern now places clones at owner/repo/<branch> where <branch> is the remote's default branch, resolved via git ls-remote --symref before cloning. This makes the clone directory a valid main-worktree slot for sibling worktree strategies. Falls back to "main" when the remote is unreachable.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #122 +/- ##
==========================================
+ Coverage 37.62% 37.85% +0.23%
==========================================
Files 28 31 +3
Lines 3216 3545 +329
==========================================
+ Hits 1210 1342 +132
- Misses 1917 2101 +184
- Partials 89 102 +13
🚀 New features to boost your workflow:
|
Owner
|
Let me think about this (Original thinking was to focus on worktrees (only)... replicating git clone/init was intentionally not considered...) |
Contributor
Author
|
Sure, take your time; I would see workspace management as a future enhancement as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Every wt command assumes you are already inside a repo. There is no way to acquire the main repository in the first place.
wt clone fills that gap.
What this adds
wt clone <owner/repo|url> [dest] — clones a repository into its canonical location for a category, left on its
default branch, ready to inspect. A worktree can be added later with the usual wt commands.
wt clone oss timvw/wt # -> ~/dev/repos/oss/timvw/wt/main
wt clone work owner/repo # -> ~/dev/repos/work/owner/repo/main
wt clone personal git@…/x.git # full URL, same layout
wt clone personal git@…/x.git ~/src/x # explicit dest, bypasses layout
Categories
A category is an organizational context: where repos live (repo_root) plus the auth profile used to reach them (gh_auth,
git_protocol, glab_host). Three builtins ship: work, personal, oss.
repo_root = "~/dev/repos" # base; category root = <repo_root>/
[categories.work]
gh_auth = "work"
git_protocol = "ssh"
[categories.personal]
gh_auth = "personal"
[categories.client]
repo_root = "~/clients/acme/src" # explicit override
glab_host = "gitlab.acme.com"
Placement pattern
Default: {.category.RepoRoot}/{.repo.Owner}/{.repo.Name}/{.branch}
{.branch} is the remote's default branch, resolved via git ls-remote --symref before cloning (fallback "main"). This makes
the clone directory a valid main-worktree slot for sibling-worktree strategies. Override with repo_pattern.
Other details
Tests