worktree

package
v0.17.14 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package worktree provides utilities for executing operations in Git worktrees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateSessionOptions

type CreateSessionOptions struct {
	// Ref is the git ref (branch, commit, tag) to checkout in the worktree.
	// If empty, defaults to trunk.
	Ref string

	// NamePattern is the pattern for the worktree directory name.
	// Uses Go's os.MkdirTemp pattern (e.g., "stackit-work-*").
	NamePattern string

	// PullTrunk determines whether to pull the latest trunk before returning.
	// Only applicable when Ref is trunk or empty.
	PullTrunk bool
}

CreateSessionOptions configures how a worktree session is created.

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor creates and manages temporary worktrees for executing operations.

func NewExecutor

func NewExecutor(eng engine.Engine, out output.Output) *Executor

NewExecutor creates a new worktree executor.

func (*Executor) CreateSession

func (e *Executor) CreateSession(ctx context.Context, opts CreateSessionOptions) (*Session, error)

CreateSession creates a new worktree session. The caller is responsible for calling Close() on the returned session.

type Session

type Session struct {
	Path   string        // Path to the worktree directory
	Engine engine.Engine // Engine initialized for the worktree
	// contains filtered or unexported fields
}

Session represents an active worktree session that can be used to execute operations. The caller must call Close() when done to clean up the worktree.

func (*Session) Close

func (s *Session) Close()

Close cleans up the worktree session. This should be called when done with the session.

func (*Session) GetCurrentRevision

func (s *Session) GetCurrentRevision(ctx context.Context) (string, error)

GetCurrentRevision returns the current commit SHA of the worktree.

func (*Session) ResetToRef

func (s *Session) ResetToRef(ctx context.Context, ref string) error

ResetToRef resets the worktree to the specified ref.

func (*Session) ResetToTrunk

func (s *Session) ResetToTrunk(ctx context.Context) error

ResetToTrunk resets the worktree to trunk.

Jump to

Keyboard shortcuts

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