Documentation
¶
Overview ¶
Package worktree provides worktree management operations.
Index ¶
- type Manager
- func (m *Manager) Create(name string, baseSnapshotID *model.SnapshotID) (*model.WorktreeConfig, error)
- func (m *Manager) CreateFromSnapshot(name string, snapshotID model.SnapshotID, ...) (*model.WorktreeConfig, error)
- func (m *Manager) CreateStartedFromSnapshot(name string, snapshotID model.SnapshotID, ...) (*model.WorktreeConfig, error)
- func (m *Manager) CreateStartedFromSnapshotAt(req StartedFromSnapshotRequest, cloneFunc func(src, dst string) error) (*model.WorktreeConfig, error)
- func (m *Manager) Fork(snapshotID model.SnapshotID, name string, ...) (*model.WorktreeConfig, error)
- func (m *Manager) Get(name string) (*model.WorktreeConfig, error)
- func (m *Manager) LastTransferRecord() (transfer.Record, bool)
- func (m *Manager) List() ([]*model.WorktreeConfig, error)
- func (m *Manager) Move(name, newFolder string) error
- func (m *Manager) MoveLocked(name, newFolder string) error
- func (m *Manager) Path(name string) (string, error)
- func (m *Manager) PlanMove(name, newFolder string) (string, string, error)
- func (m *Manager) PlannedStartedFromPath(name string) (string, error)
- func (m *Manager) PlannedStartedFromWorkspace(req StartedFromSnapshotRequest) (string, error)
- func (m *Manager) RebindRealPath(name, realPath string) error
- func (m *Manager) Remove(name string) error
- func (m *Manager) RemoveLocked(name string) error
- func (m *Manager) Rename(oldName, newName string) error
- func (m *Manager) RenameLocked(oldName, newName string) error
- func (m *Manager) SetLatest(name string, snapshotID model.SnapshotID) error
- func (m *Manager) UpdateHead(name string, snapshotID model.SnapshotID) error
- type StartedFromSnapshotRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles worktree CRUD operations.
func NewManager ¶
NewManager creates a new worktree manager.
func (*Manager) Create ¶
func (m *Manager) Create(name string, baseSnapshotID *model.SnapshotID) (*model.WorktreeConfig, error)
Create creates a new worktree with the given name.
func (*Manager) CreateFromSnapshot ¶
func (m *Manager) CreateFromSnapshot(name string, snapshotID model.SnapshotID, cloneFunc func(src, dst string) error) (*model.WorktreeConfig, error)
CreateFromSnapshot creates a new worktree with content cloned from a snapshot. This is similar to Fork but uses "create" semantics (for the --from flag).
func (*Manager) CreateStartedFromSnapshot ¶
func (m *Manager) CreateStartedFromSnapshot(name string, snapshotID model.SnapshotID, cloneFunc func(src, dst string) error) (*model.WorktreeConfig, error)
CreateStartedFromSnapshot creates a new workspace whose files come from a save point, without inheriting that save point as workspace history.
func (*Manager) CreateStartedFromSnapshotAt ¶ added in v0.4.7
func (m *Manager) CreateStartedFromSnapshotAt(req StartedFromSnapshotRequest, cloneFunc func(src, dst string) error) (*model.WorktreeConfig, error)
CreateStartedFromSnapshotAt creates a new workspace at an explicit folder. If req.Name is empty, the workspace name is derived from req.Folder's basename.
func (*Manager) Fork ¶
func (m *Manager) Fork(snapshotID model.SnapshotID, name string, cloneFunc func(src, dst string) error) (*model.WorktreeConfig, error)
Fork creates a new worktree from a snapshot with content cloned. The new worktree will be at HEAD state (can create snapshots immediately).
func (*Manager) Get ¶
func (m *Manager) Get(name string) (*model.WorktreeConfig, error)
Get returns the config for a specific worktree.
func (*Manager) LastTransferRecord ¶ added in v0.4.7
LastTransferRecord returns the final primary transfer from the most recent successful filesystem-aware workspace materialization handled by this manager.
func (*Manager) List ¶
func (m *Manager) List() ([]*model.WorktreeConfig, error)
List returns all worktrees.
func (*Manager) Move ¶ added in v0.4.7
Move moves a workspace folder without changing the workspace name.
func (*Manager) MoveLocked ¶ added in v0.4.7
MoveLocked performs Move while the caller already holds the repository mutation lock.
func (*Manager) PlanMove ¶ added in v0.4.7
PlanMove validates a path-only workspace move and returns the current and target folders without mutating either metadata or files.
func (*Manager) PlannedStartedFromPath ¶
PlannedStartedFromPath returns the workspace folder that CreateStartedFromSnapshot would publish, without creating staging, payload, or metadata paths.
func (*Manager) PlannedStartedFromWorkspace ¶ added in v0.4.7
func (m *Manager) PlannedStartedFromWorkspace(req StartedFromSnapshotRequest) (string, error)
PlannedStartedFromWorkspace returns the explicit workspace folder after validating the requested name, target, and current workspace registry.
func (*Manager) RebindRealPath ¶
RebindRealPath updates the workspace's destination-local real path after the caller has determined that the new binding is safe.
func (*Manager) RemoveLocked ¶ added in v0.4.7
RemoveLocked performs Remove while the caller already holds the repository mutation lock.
func (*Manager) RenameLocked ¶ added in v0.4.7
RenameLocked performs Rename while the caller already holds the repository mutation lock.
func (*Manager) SetLatest ¶
func (m *Manager) SetLatest(name string, snapshotID model.SnapshotID) error
SetLatest updates both head and latest snapshot IDs for a worktree. This is used by snapshot creation to mark a new latest state.
func (*Manager) UpdateHead ¶
func (m *Manager) UpdateHead(name string, snapshotID model.SnapshotID) error
UpdateHead atomically updates the head snapshot ID for a worktree. This is used by restore to move to a different point in history.
type StartedFromSnapshotRequest ¶ added in v0.4.7
type StartedFromSnapshotRequest struct {
Name string
Folder string
SnapshotID model.SnapshotID
RequestedEngine model.EngineType
TransferPlanner transfer.EnginePlanner
}
StartedFromSnapshotRequest describes a new workspace folder whose initial files come from a save point.