gitcontrol

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package gitcontrol runs the fixed Git plumbing operations required by the Coding Team Worktree control plane.

It deliberately exposes typed operations instead of arbitrary process arguments. The package is trusted application infrastructure, not a model-callable shell or an Approval bypass.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalid means an operation value cannot name a safe fixed Git command.
	ErrInvalid = errors.New("coding git control: invalid operation")
	// ErrUnsupported means the current platform cannot provide the required
	// process and filesystem identity guarantees.
	ErrUnsupported = errors.New("coding git control: unsupported platform")
	// ErrExecutableChanged means the injected Git executable was replaced.
	ErrExecutableChanged = errors.New("coding git control: executable identity changed")
	// ErrLimit means a command input, output, or time budget was exceeded.
	ErrLimit = errors.New("coding git control: resource limit exceeded")
	// ErrGit means a fixed Git command did not complete successfully.
	ErrGit = errors.New("coding git control: git command failed")
	// ErrNotFound means an exact ref, object, or Worktree record is absent.
	ErrNotFound = errors.New("coding git control: resource not found")
	// ErrConflict means an expected-old-value or exact identity did not match.
	ErrConflict = errors.New("coding git control: identity conflict")
	// ErrUnsafeConfig means repository configuration could execute external code.
	ErrUnsafeConfig = errors.New("coding git control: unsafe repository config")
)

Functions

This section is empty.

Types

type Commit

type Commit struct {
	TreeOID   string
	ParentOID string
	Message   string
	Timestamp time.Time
}

Commit identifies one commit-tree result.

type IndexEntry

type IndexEntry struct {
	Mode string
	OID  string
	Path string
}

IndexEntry is one exact temporary-index cache entry. Mode "0" deletes Path.

type Limits

type Limits struct {
	OutputBytes int64
	InputBytes  int64
	Timeout     time.Duration
	TreeEntries int
}

Limits bounds every trusted Git process and parsed collection.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns conservative production Git-control budgets.

type RefUpdate

type RefUpdate struct {
	Ref    string
	NewOID string
	OldOID string
	Create bool
	Delete bool
}

RefUpdate is one update-ref transaction item.

type Repository

type Repository struct {
	TopLevel     string
	GitDir       string
	CommonDir    string
	ObjectFormat string
	HeadOID      string
	BranchRef    string
}

Repository is one resolved Git repository/worktree identity projection.

type Runner

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

Runner executes only the package's fixed Git operation families.

func New

func New(gitPath string, limits Limits) (*Runner, error)

New returns a trusted Git runner bound to one exact executable identity.

func (*Runner) AddWorktree

func (r *Runner) AddWorktree(ctx context.Context, directory, path, branch, reason string) error

AddWorktree creates an already-locked linked Worktree without checkout.

func (*Runner) CatBlob

func (r *Runner) CatBlob(ctx context.Context, directory, oid string) ([]byte, error)

CatBlob returns the exact bytes for one blob OID.

func (*Runner) CheckIgnored

func (r *Runner) CheckIgnored(ctx context.Context, directory string, paths []string) (map[string]struct{}, error)

CheckIgnored returns the input paths ignored by repository rules.

func (*Runner) CommitTree

func (r *Runner) CommitTree(ctx context.Context, directory string, commit Commit) (string, error)

CommitTree creates one single-parent commit from exact plumbing inputs.

func (*Runner) CreateRef

func (r *Runner) CreateRef(
	ctx context.Context,
	directory, objectFormat, ref, oid, reason string,
) error

CreateRef CAS-creates ref at oid.

func (*Runner) DeleteRef

func (r *Runner) DeleteRef(ctx context.Context, directory, ref, oldOID, reason string) error

DeleteRef CAS-deletes ref only when it still contains oldOID.

func (*Runner) HashBlob

func (r *Runner) HashBlob(ctx context.Context, directory string, content []byte) (string, error)

HashBlob stores raw bytes without attributes or filters and returns the OID.

func (*Runner) InspectRepository

func (r *Runner) InspectRepository(ctx context.Context, directory string) (Repository, error)

InspectRepository resolves repository identity and exact HEAD metadata.

func (*Runner) ListTree

func (r *Runner) ListTree(ctx context.Context, directory, treeOID string) ([]TreeEntry, error)

ListTree returns every recursive leaf in treeOID.

func (*Runner) LockWorktree

func (r *Runner) LockWorktree(ctx context.Context, directory, path, reason string) error

LockWorktree locks one exact linked Worktree with the owned reason.

func (*Runner) ReadTree

func (r *Runner) ReadTree(ctx context.Context, directory, indexPath, treeOID string) error

ReadTree initializes indexPath from treeOID without updating files.

func (*Runner) RemoveWorktree

func (r *Runner) RemoveWorktree(ctx context.Context, directory, path string) error

RemoveWorktree removes one clean exact linked Worktree without force.

func (*Runner) ResolveCommit

func (r *Runner) ResolveCommit(ctx context.Context, directory, value string) (string, error)

ResolveCommit resolves value and requires a commit object.

func (*Runner) ResolveRef

func (r *Runner) ResolveRef(ctx context.Context, directory, ref string) (string, error)

ResolveRef returns the exact OID stored in ref.

func (*Runner) ResolveTree

func (r *Runner) ResolveTree(ctx context.Context, directory, commitOID string) (string, error)

ResolveTree returns the exact tree OID for one commit OID.

func (*Runner) SnapshotStatus

func (r *Runner) SnapshotStatus(ctx context.Context, directory string) (Status, error)

SnapshotStatus returns a stable digest of tracked and untracked Worktree state without refreshing or mutating the index.

func (*Runner) UnlockWorktree

func (r *Runner) UnlockWorktree(ctx context.Context, directory, path string) error

UnlockWorktree unlocks one exact linked Worktree.

func (*Runner) UnmergedIndex

func (r *Runner) UnmergedIndex(ctx context.Context, directory, indexPath string) (bool, error)

UnmergedIndex returns whether indexPath contains an unmerged entry.

func (*Runner) UpdateIndex

func (r *Runner) UpdateIndex(
	ctx context.Context,
	directory, indexPath, objectFormat string,
	entries []IndexEntry,
) error

UpdateIndex replaces temporary-index entries using the machine NUL protocol.

func (*Runner) UpdateRefs

func (r *Runner) UpdateRefs(
	ctx context.Context,
	directory, objectFormat, reason string,
	updates []RefUpdate,
) error

UpdateRefs publishes one atomic expected-value ref transaction.

func (*Runner) ValidateSafeConfig

func (r *Runner) ValidateSafeConfig(ctx context.Context, directory string) error

ValidateSafeConfig rejects effective repository configuration that can execute an external program in a lifecycle command.

func (*Runner) Worktrees

func (r *Runner) Worktrees(ctx context.Context, directory string) ([]Worktree, error)

Worktrees returns the stable machine Worktree list.

func (*Runner) WriteTree

func (r *Runner) WriteTree(ctx context.Context, directory, indexPath string) (string, error)

WriteTree writes the fully merged temporary index and returns its tree OID.

type Status

type Status struct {
	Clean  bool
	Digest string
	Paths  []string
}

Status is the exact machine-status snapshot of one Worktree.

type TreeEntry

type TreeEntry struct {
	Mode string
	Type string
	OID  string
	Path string
}

TreeEntry is one recursive Git tree leaf.

type Worktree

type Worktree struct {
	Path       string
	HeadOID    string
	BranchRef  string
	Detached   bool
	Bare       bool
	Locked     bool
	LockReason string
	Prunable   bool
}

Worktree is one record from worktree list --porcelain -z.

Jump to

Keyboard shortcuts

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