Documentation
¶
Overview ¶
Package worktree owns the git worktree lifecycle and diff capture, all through the Executor interface so it works identically on every target kind.
Index ¶
- func AddExcludes(ctx context.Context, ex executor.Executor, repoDir string) error
- func BranchName(taskID int64, attemptN int) string
- func DefaultWorkroot(repoPath string) string
- func Ensure(ctx context.Context, ex executor.Executor, ...) error
- func NamespacedBranch(branch, namespace string) string
- func NamespacedWorkroot(workroot, namespace string) string
- func Path(workroot string, taskID int64, attemptN int) string
- func Remove(ctx context.Context, ex executor.Executor, repo, path string) error
- func RunInteractive(ctx context.Context, ex executor.Executor, action string, plan *Interactive) error
- func RunInteractiveWithTimeout(ctx context.Context, ex executor.Executor, action string, plan *Interactive, ...) error
- type FilePatch
- type FileStat
- type Interactive
- type InteractiveOptions
- type RepositorySelection
- type RepositorySource
- type WorkspaceRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddExcludes ¶
AddExcludes keeps our runtime dir and verify-run artifacts out of git status/diff/commit. Verify artifacts leaking into `git add -A` was a real bug found only on a live dispatch.
func BranchName ¶
BranchName is the branch one attempt works on.
func DefaultWorkroot ¶
DefaultWorkroot puts worktrees beside the repo, not inside it.
func Ensure ¶
Ensure creates the attempt's worktree, tolerating one that already exists — follow-up attempts and the reviewer gate deliberately reuse it.
func NamespacedBranch ¶
NamespacedBranch scopes an automatically-created branch to one runtime.
func NamespacedWorkroot ¶
NamespacedWorkroot keeps automatically-created allocations from separate control-plane instances out of one another's default directory.
func RunInteractive ¶
Types ¶
type FilePatch ¶
FilePatch is one file's slice of a unified diff, for the mobile viewer.
func SplitPatch ¶
SplitPatch slices a unified diff into per-file chunks.
type FileStat ¶
type FileStat struct {
Path string `json:"path"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
}
FileStat is one file's line churn in a captured diff.
type Interactive ¶
type Interactive struct {
OperationActive bool `json:"operation_active,omitempty"`
ControlToken string `json:"control_token,omitempty"`
SetupCommand string `json:"setup_command,omitempty"`
SetupEnv map[string]string `json:"setup_env,omitempty"`
SetupState string `json:"setup_state,omitempty"`
SetupOutput string `json:"setup_output,omitempty"`
Repo string `json:"repo"`
Path string `json:"path"`
Branch string `json:"branch"`
Base string `json:"base"`
Commit string `json:"commit"`
Token string `json:"token,omitempty"`
State string `json:"state"`
Error string `json:"error,omitempty"`
Repositories []WorkspaceRepository `json:"repositories,omitempty"`
}
Interactive records an allocation before any remote Git mutation. A failed launch keeps this record so the directory is still discoverable and removable.
func PlanInteractive ¶
func PlanInteractive(repo string, id int64, o InteractiveOptions) *Interactive
func PlanMultiWorkspace ¶
func PlanMultiWorkspace(sources []RepositorySource, id int64, options InteractiveOptions) (*Interactive, error)
PlanMultiWorkspace creates only a plan. It never touches Git or the filesystem. Each repository has its own ownership token, base and allocation state.
func PlanWorkspaceExtension ¶
func PlanWorkspaceExtension(existing *Interactive, source RepositorySource, id int64) (*Interactive, error)
PlanWorkspaceExtension preserves existing ownership and stages one new child. The worker must validate the complete plan against the live root receipt.
func (*Interactive) HasSetupCommand ¶
func (p *Interactive) HasSetupCommand() bool
HasSetupCommand gives package installation a longer overall setup deadline.
func (*Interactive) RedactOwnership ¶
func (p *Interactive) RedactOwnership()
RedactOwnership removes all allocation tokens before an API response. It is applied to a decoded copy, never to the persisted ownership records.
type InteractiveOptions ¶
type InteractiveOptions struct {
Base string `json:"base"`
Branch string `json:"branch"`
Namespace string `json:"-"`
Workroot string `json:"-"`
ExtraRepositories []RepositorySelection `json:"extra_repositories,omitempty"`
}
type RepositorySelection ¶
type RepositorySource ¶
type RepositorySource struct {
Name, Repo, Base string
SetupCommand string
SetupEnv map[string]string
ProjectID *int64
}
RepositorySource is resolved from registered projects on one target before planning; paths and Git identities must still be verified on that target.
type WorkspaceRepository ¶
type WorkspaceRepository struct {
Name string `json:"name"`
ProjectID *int64 `json:"project_id,omitempty"`
Worktree *Interactive `json:"worktree"`
}
WorkspaceRepository records each allocation independently, including a failed or removed one. The enclosing workspace owns the root directory separately.