Documentation
¶
Index ¶
- func RunGitCommand(ctx context.Context, dir string, args ...string) (out string, rerr error)
- func RunInteractiveGitCommand(ctx context.Context, dir string, w io.Writer, args ...string) (rerr error)
- type LockType
- type Repository
- func (r *Repository) Apply(ctx context.Context, id string, w io.Writer) error
- func (r *Repository) Checkout(ctx context.Context, id, branch string) (string, error)
- func (r *Repository) Create(ctx context.Context, dag *dagger.Client, ...) (*environment.Environment, error)
- func (r *Repository) Delete(ctx context.Context, id string) error
- func (r *Repository) Diff(ctx context.Context, id string, w io.Writer) error
- func (r *Repository) Get(ctx context.Context, dag *dagger.Client, id string) (*environment.Environment, error)
- func (r *Repository) Info(ctx context.Context, id string) (*environment.EnvironmentInfo, error)
- func (r *Repository) IsDirty(ctx context.Context) (bool, string, error)
- func (r *Repository) List(ctx context.Context) ([]*environment.EnvironmentInfo, error)
- func (r *Repository) ListDescendantEnvironments(ctx context.Context, ancestorCommit string) ([]*environment.EnvironmentInfo, error)
- func (r *Repository) Log(ctx context.Context, id string, patch bool, w io.Writer) error
- func (r *Repository) Merge(ctx context.Context, id string, w io.Writer) error
- func (r *Repository) SourcePath() string
- func (r *Repository) Update(ctx context.Context, env *environment.Environment, explanation string) error
- func (r *Repository) WorktreePath(id string) (string, error)
- type RepositoryLock
- func (rl *RepositoryLock) Lock(ctx context.Context) error
- func (rl *RepositoryLock) RLock(ctx context.Context) error
- func (rl *RepositoryLock) Unlock() error
- func (rl *RepositoryLock) WithLock(ctx context.Context, fn func() error) error
- func (rl *RepositoryLock) WithRLock(ctx context.Context, fn func() error) error
- type RepositoryLockManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunGitCommand ¶
RunGitCommand executes a git command in the specified directory. This is exported for use in tests and other packages that need direct git access.
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 OpenWithBasePath ¶
OpenWithBasePath opens a repository with a custom base path for container-use data. This is useful for tests that need isolated environments.
func (*Repository) Checkout ¶
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) Get ¶
func (r *Repository) Get(ctx context.Context, dag *dagger.Client, id string) (*environment.Environment, error)
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 ¶
func (r *Repository) Info(ctx context.Context, id string) (*environment.EnvironmentInfo, error)
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) List ¶
func (r *Repository) List(ctx context.Context) ([]*environment.EnvironmentInfo, error)
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) 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.
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.