Documentation
¶
Overview ¶
Package git will adapt git operations for the Go port.
Index ¶
- func DetachedPRWorktreePath(worktreeRoot, projectID string, prNumber int64) string
- func IsReservedReviewerScratchBaseName(name string) bool
- func ScrubReservedReviewerScratch(ctx context.Context, gitPath, worktreePath string) error
- type CheckoutMode
- type CleanupWorktreeInput
- type CommitInput
- type CommitResult
- type CreateWorktreeInput
- type DiscardWorktreeChangesInput
- type DiscardWorktreeChangesResult
- type Gateway
- func (g *Gateway) AssertWritableBranch(branch string, protectedBranches []string) error
- func (g *Gateway) CleanupWorktree(ctx context.Context, input CleanupWorktreeInput) error
- func (g *Gateway) Commit(ctx context.Context, input CommitInput) (CommitResult, error)
- func (g *Gateway) CreateBranch(ctx context.Context, repoPath, branch, startPoint string, ...) error
- func (g *Gateway) CreateWorktree(ctx context.Context, input CreateWorktreeInput) (storage.WorktreeRecord, error)
- func (g *Gateway) DetectGitHubRepo(ctx context.Context, repoPath string) (string, error)
- func (g *Gateway) DetectOriginRemote(ctx context.Context, repoPath string) (OriginRemote, error)
- func (g *Gateway) DiscardWorktreeChanges(ctx context.Context, input DiscardWorktreeChangesInput) (DiscardWorktreeChangesResult, error)
- func (g *Gateway) FetchBranch(ctx context.Context, repoPath, remote, branch string) error
- func (g *Gateway) InspectHead(ctx context.Context, input InspectHeadInput) (InspectHeadResult, error)
- func (g *Gateway) IsAncestor(ctx context.Context, repoPath, ancestor, descendant string) (bool, error)
- func (g *Gateway) IsWorktreeClean(ctx context.Context, worktreePath string) (bool, error)
- func (g *Gateway) ListWorktrees(ctx context.Context, repoPath string) ([]WorktreeListEntry, error)
- func (g *Gateway) MergeBaseIntoWorktree(ctx context.Context, input MergeBaseInput) (MergeBaseResult, error)
- func (g *Gateway) PrepareWorktree(ctx context.Context, input PrepareWorktreeInput) (PrepareWorktreeResult, error)
- func (g *Gateway) Push(ctx context.Context, input PushInput) error
- func (g *Gateway) RestoreWorktree(ctx context.Context, input RestoreWorktreeInput) (*storage.WorktreeRecord, error)
- func (g *Gateway) ScrubReservedReviewerScratch(ctx context.Context, worktreePath string) error
- func (g *Gateway) WorktreeClean(ctx context.Context, worktreePath string) (bool, error)
- type InspectHeadInput
- type InspectHeadResult
- type MergeBaseInput
- type MergeBaseResult
- type Options
- type OriginRemote
- type PrepareWorktreeInput
- type PrepareWorktreeResult
- type ProtectedBranchError
- type PushInput
- type RemoteHeadChangedError
- type RestoreWorktreeInput
- type WorktreeListEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetachedPRWorktreePath ¶ added in v0.11.1
DetachedPRWorktreePath returns the managed shared detached worktree path that CreateWorktree claims for a PR (looper-fix-<project>-pr-<N>-detached). Callers that must read ownership markers before CreateWorktree revokes them should probe this candidate path even when no checkpoint worktree exists.
func IsReservedReviewerScratchBaseName ¶ added in v0.11.3
IsReservedReviewerScratchBaseName reports whether name matches the disposable reviewer scratch grammar (exported for focused tests).
func ScrubReservedReviewerScratch ¶ added in v0.11.3
ScrubReservedReviewerScratch removes disposable reviewer submit scratch from a managed worktree root immediately before ordinary PrepareWorktree cleanliness.
It enumerates the worktree root directly (not via git status). Only regular files matching reservedReviewerScratchBaseName that are absent from both the Git index and HEAD tree are deleted. Symlinks and directories are left alone. Files tracked by HEAD but staged for index removal (e.g. after `git rm --cached`) remain ordinary dirt and are preserved. Delete failures fail closed.
gitPath must be the configured Git executable (tools.gitPath); callers must not hard-code "git" when a non-PATH binary is configured.
Types ¶
type CheckoutMode ¶
type CheckoutMode string
const ( CheckoutModeBranch CheckoutMode = "branch" CheckoutModeDetached CheckoutMode = "detached" )
type CleanupWorktreeInput ¶
type CleanupWorktreeInput struct {
ProjectID string
RepoPath string
WorktreeRoot string
WorktreePath string
Branch string
ProtectedBranches []string
// AdmitStart, when set, wraps the destructive `git worktree remove`
// process Start so callers can hold admission across Start only (not
// Wait). Runtime cleanup uses this for R7 atomicity with MarkDegraded:
// point-in-time AllowClaim leaves a window before cmd.Start.
AdmitStart func(start func() error) error
}
type CommitInput ¶
type CommitResult ¶
type CommitResult struct {
CommitSHA string
}
type CreateWorktreeInput ¶
type DiscardWorktreeChangesInput ¶ added in v0.11.0
DiscardWorktreeChangesInput discards tracked and untracked local changes in a managed worktree, leaving HEAD and the worktree directory itself intact.
type DiscardWorktreeChangesResult ¶ added in v0.11.0
DiscardWorktreeChangesResult reports whether discard mutated the worktree.
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
func (*Gateway) AssertWritableBranch ¶
func (*Gateway) CleanupWorktree ¶
func (g *Gateway) CleanupWorktree(ctx context.Context, input CleanupWorktreeInput) error
func (*Gateway) Commit ¶
func (g *Gateway) Commit(ctx context.Context, input CommitInput) (CommitResult, error)
func (*Gateway) CreateBranch ¶
func (*Gateway) CreateWorktree ¶
func (g *Gateway) CreateWorktree(ctx context.Context, input CreateWorktreeInput) (storage.WorktreeRecord, error)
func (*Gateway) DetectGitHubRepo ¶
func (*Gateway) DetectOriginRemote ¶ added in v0.10.4
DetectOriginRemote reads remote.origin.url and extracts host + owner/name when possible.
func (*Gateway) DiscardWorktreeChanges ¶ added in v0.11.0
func (g *Gateway) DiscardWorktreeChanges(ctx context.Context, input DiscardWorktreeChangesInput) (DiscardWorktreeChangesResult, error)
DiscardWorktreeChanges hard-resets tracked files and removes untracked files in a managed worktree. It never deletes the worktree directory, remote branches, or force-pushes.
func (*Gateway) FetchBranch ¶ added in v0.7.4
func (*Gateway) InspectHead ¶
func (g *Gateway) InspectHead(ctx context.Context, input InspectHeadInput) (InspectHeadResult, error)
func (*Gateway) IsAncestor ¶ added in v0.7.4
func (*Gateway) IsWorktreeClean ¶ added in v0.9.0
func (*Gateway) ListWorktrees ¶
func (*Gateway) MergeBaseIntoWorktree ¶ added in v0.10.0
func (g *Gateway) MergeBaseIntoWorktree(ctx context.Context, input MergeBaseInput) (MergeBaseResult, error)
MergeBaseIntoWorktree fetches the base branch and merges it into the worktree. On a clean merge it returns AlreadyUpToDate as appropriate; on conflicts it leaves the conflict markers in place and returns Conflicted=true so the caller can hand the worktree to an agent; on any other merge failure it aborts to keep the worktree clean and returns the error.
func (*Gateway) PrepareWorktree ¶
func (g *Gateway) PrepareWorktree(ctx context.Context, input PrepareWorktreeInput) (PrepareWorktreeResult, error)
func (*Gateway) RestoreWorktree ¶
func (g *Gateway) RestoreWorktree(ctx context.Context, input RestoreWorktreeInput) (*storage.WorktreeRecord, error)
func (*Gateway) ScrubReservedReviewerScratch ¶ added in v0.11.3
ScrubReservedReviewerScratch removes disposable reviewer submit scratch using this gateway's configured Git executable.
type InspectHeadInput ¶
type InspectHeadResult ¶
type MergeBaseInput ¶ added in v0.10.0
MergeBaseInput asks to merge a remote base branch into a worktree.
type MergeBaseResult ¶ added in v0.10.0
type MergeBaseResult struct {
AlreadyUpToDate bool
// Conflicted is true when the merge left conflict markers in the worktree for
// an agent to resolve (the merge is intentionally NOT aborted in that case).
Conflicted bool
}
MergeBaseResult reports the outcome of a base merge.
type Options ¶
type Options struct {
GitPath string
Repos *storage.Repositories
Now func() time.Time
}
type OriginRemote ¶ added in v0.10.4
OriginRemote is the parsed remote.origin URL for a local checkout.
type PrepareWorktreeInput ¶
type PrepareWorktreeResult ¶
type ProtectedBranchError ¶
type ProtectedBranchError struct {
Branch string
}
func (*ProtectedBranchError) Error ¶
func (e *ProtectedBranchError) Error() string
type RemoteHeadChangedError ¶
func (*RemoteHeadChangedError) Error ¶
func (e *RemoteHeadChangedError) Error() string