repository

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunGitCommand

func RunGitCommand(ctx context.Context, dir string, args ...string) (out string, rerr error)

RunGitCommand executes a git command in the specified directory. This is exported for use in tests and other packages that need direct git access.

func RunInteractiveGitCommand added in v0.2.0

func RunInteractiveGitCommand(ctx context.Context, dir string, w io.Writer, args ...string) (rerr error)

RunInteractiveGitCommand executes a git command in the specified directory in interactive mode.

Types

type LockType added in v0.4.2

type LockType string

LockType represents different types of operations that can be locked

const (
	// LockTypeUserRepo - Git operations on the environment_source repo (changing remotes, fetching)
	LockTypeUserRepo LockType = "user-repo"
	// LockTypeForkRepo - Git operations on our fork (~/.config/container-use/repos/$repo)
	// Used for committing, creating worktrees, uploading from worktrees (should be rlock for uploads)
	LockTypeForkRepo LockType = "fork-repo"
	// LockTypeNotes - Subset of fork repo operations for saving state, notes etc
	// Notes are a global ref to that repository and we do many operations against them
	LockTypeNotes LockType = "notes"
)

type Repository

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

func Open

func Open(ctx context.Context, repo string) (*Repository, error)

func OpenWithBasePath

func OpenWithBasePath(ctx context.Context, repo string, basePath string) (*Repository, error)

OpenWithBasePath opens a repository with a custom base path for container-use data. This is useful for tests that need isolated environments.

func (*Repository) Apply added in v0.3.0

func (r *Repository) Apply(ctx context.Context, id string, w io.Writer) error

func (*Repository) Checkout

func (r *Repository) Checkout(ctx context.Context, id, branch string) (string, error)

Checkout changes the user's current branch to that of the identified environment. It attempts to get the most recent commit from the environment without discarding any user changes.

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, dag *dagger.Client, description, explanation, gitRef string) (*environment.Environment, error)

Create creates a new environment with the given description, explanation, and optional git reference. The git reference can be HEAD (default), a SHA, a branch name, or a tag. Requires a dagger client for container operations during environment initialization.

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, id string) error

Delete removes an environment from the repository.

func (*Repository) Diff added in v0.1.1

func (r *Repository) Diff(ctx context.Context, id string, w io.Writer) error

func (*Repository) Get

Get retrieves a full Environment with dagger client embedded for container operations. Use this when you need to perform container operations like running commands, terminals, etc. For basic metadata access without container operations, use Info() instead.

func (*Repository) Info

Info retrieves environment metadata without requiring dagger operations. This is more efficient than Get() when you only need access to configuration, state, and other metadata without performing container operations.

func (*Repository) IsDirty added in v0.2.0

func (r *Repository) IsDirty(ctx context.Context) (bool, string, error)

func (*Repository) List

List returns information about all environments in the repository. Returns EnvironmentInfo slice avoiding dagger client initialization. Use Get() on individual environments when you need full Environment with container operations.

func (*Repository) ListDescendantEnvironments added in v0.4.1

func (r *Repository) ListDescendantEnvironments(ctx context.Context, ancestorCommit string) ([]*environment.EnvironmentInfo, error)

ListDescendantEnvironments returns environments that are descendants of the given commit. This filters environments to only those where the provided commit is an ancestor of the environment's current HEAD. Environments are sorted by most recently updated first.

func (*Repository) Log added in v0.1.1

func (r *Repository) Log(ctx context.Context, id string, patch bool, w io.Writer) error

func (*Repository) Merge added in v0.2.0

func (r *Repository) Merge(ctx context.Context, id string, w io.Writer) error

func (*Repository) SourcePath

func (r *Repository) SourcePath() string

func (*Repository) Update

func (r *Repository) Update(ctx context.Context, env *environment.Environment, explanation string) error

Update saves the provided environment to the repository. Writes configuration and source code changes to the worktree and history + state to git notes.

func (*Repository) WorktreePath added in v0.2.0

func (r *Repository) WorktreePath(id string) (string, error)

type RepositoryLock added in v0.4.2

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

RepositoryLock provides process-level locking for specific operation types

func (*RepositoryLock) Lock added in v0.4.2

func (rl *RepositoryLock) Lock(ctx context.Context) error

Lock acquires an exclusive repository lock.

func (*RepositoryLock) RLock added in v0.4.2

func (rl *RepositoryLock) RLock(ctx context.Context) error

RLock acquires a shared repository lock. Multiple processes can hold shared locks simultaneously.

func (*RepositoryLock) Unlock added in v0.4.2

func (rl *RepositoryLock) Unlock() error

Unlock releases the repository lock.

func (*RepositoryLock) WithLock added in v0.4.2

func (rl *RepositoryLock) WithLock(ctx context.Context, fn func() error) error

WithLock executes a function while holding an exclusive lock.

func (*RepositoryLock) WithRLock added in v0.4.2

func (rl *RepositoryLock) WithRLock(ctx context.Context, fn func() error) error

WithRLock executes a function while holding a shared lock.

type RepositoryLockManager added in v0.4.2

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

RepositoryLockManager provides granular process-level locking for repository operations to prevent git concurrency issues when multiple container-use instances operate on the same repository simultaneously.

func NewRepositoryLockManager added in v0.4.2

func NewRepositoryLockManager(repoPath string) *RepositoryLockManager

NewRepositoryLockManager creates a new repository lock manager for the given repository path.

func (*RepositoryLockManager) GetLock added in v0.4.2

func (rlm *RepositoryLockManager) GetLock(lockType LockType) *RepositoryLock

GetLock returns a lock for the specified operation type

func (*RepositoryLockManager) WithLock added in v0.4.2

func (rlm *RepositoryLockManager) WithLock(ctx context.Context, lockType LockType, fn func() error) error

WithLock executes a function while holding an exclusive lock for the specified lock type

func (*RepositoryLockManager) WithRLock added in v0.4.2

func (rlm *RepositoryLockManager) WithRLock(ctx context.Context, lockType LockType, fn func() error) error

WithRLock executes a function while holding a shared (read) lock for the specified lock type. Multiple readers can hold the lock simultaneously, but writers will block until all readers release.

Jump to

Keyboard shortcuts

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