Documentation
¶
Overview ¶
Package worktree manages cloned workspaces for instance isolation. When a workspace path is a git repository, a local clone is created so each instance gets its own self-contained .git directory that works inside containers without additional volume mounts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(repoDir, clonePath string, opts ...CreateOptions) error
Create creates a local clone at clonePath from the given repository directory. It uses `git clone --local --no-checkout` for efficiency (hardlinks objects on the same filesystem), then checks out a detached HEAD at origin/<default-branch> and fixes up the origin remote URL to point at the upstream remote rather than the local repo path.
Unless opts.NoFetch is set, origin is fetched first so the clone reflects the latest remote state. Fetch failures are non-fatal: a warning is emitted and creation continues with existing local state.
The resulting clone has a self-contained .git directory that works inside containers without additional volume mounts.
func DefaultBranch ¶
DefaultBranch returns the default branch of the remote "origin" in the given git repository. It runs `git symbolic-ref` and parses the HEAD branch. Falls back to "main" if the default branch cannot be determined.
Types ¶
type CreateOptions ¶
type CreateOptions struct {
// NoFetch skips the "git fetch origin" step before cloning.
// When false (the default), origin is fetched so the clone reflects
// up-to-date remote state.
NoFetch bool
// Warnings receives non-fatal warning messages (e.g. fetch failures).
// When nil, warnings are silently discarded.
Warnings io.Writer
}
CreateOptions configures the behavior of Create.