worktree

package
v0.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPatch

func ApplyPatch(repoPath, patch string) error

ApplyPatch applies a patch to a repository. Returns nil if patch is empty.

func CheckPatch

func CheckPatch(repoPath, patch string) error

CheckPatch does a dry-run apply to check if a patch applies cleanly. Returns a *PatchConflictError when the patch fails due to conflicts, or a plain error for other failures (malformed patch, etc.).

Types

type PatchConflictError

type PatchConflictError struct {
	Detail string
}

PatchConflictError indicates the patch does not apply due to merge conflicts. Other errors (malformed patch, permission errors) are returned as plain errors.

func (*PatchConflictError) Error

func (e *PatchConflictError) Error() string

type Worktree

type Worktree struct {
	Dir string // Path to the worktree directory
	// contains filtered or unexported fields
}

Worktree represents a temporary git worktree for isolated agent work. Call Close to remove the worktree and its directory.

func Create

func Create(repoPath, ref string) (*Worktree, error)

Create creates a temporary git worktree detached at the given ref for isolated agent work. Pass "HEAD" for the current checkout.

func (*Worktree) CapturePatch

func (w *Worktree) CapturePatch() (string, error)

CapturePatch stages all changes in the worktree and returns the diff as a patch string. Returns empty string if there are no changes. Handles both uncommitted and committed changes by diffing the final tree state against the base SHA.

func (*Worktree) Close

func (w *Worktree) Close()

Close removes the worktree and its directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL