Documentation
¶
Overview ¶
Package git attributes workspace changes relative to an in-memory-owned baseline using fixed read-only Git commands.
Index ¶
- Constants
- Variables
- type Changes
- type Config
- type Inspector
- func (i *Inspector) Capture(ctx context.Context) (changes.Snapshot, error)
- func (i *Inspector) Changes(ctx context.Context, snapshot changes.Snapshot) (_ changes.Report, returnErr error)
- func (i *Inspector) Close() error
- func (i *Inspector) CommitChanges(ctx context.Context, base string, bytes int64, timeout time.Duration) (Changes, error)
- func (i *Inspector) ExcludeLocal(ctx context.Context, name string) error
- func (i *Inspector) Head(ctx context.Context, timeout time.Duration) (string, error)
- func (i *Inspector) ListWorkspaceFiles(ctx context.Context) ([]string, bool, error)
- func (i *Inspector) Status(ctx context.Context) (changes.WorktreeStatus, error)
- func (i *Inspector) Tracked(ctx context.Context, name string) (bool, bool, error)
- type Limits
Constants ¶
const ( // DefaultDiffBytes caps one captured commit-diff body. DefaultDiffBytes int64 = 256 << 10 // DefaultDiffTimeout bounds one commit-diff capture. DefaultDiffTimeout = 5 * time.Minute // HeadCaptureTimeout bounds the best-effort HEAD resolve. HeadCaptureTimeout = time.Second )
The commit-capture bounds are the reference's own: a 256 KiB diff body and a five-minute Git budget, with a one-second budget for the best-effort baseline resolve at Goal creation.
Variables ¶
var ( // ErrNotRepository means the workspace is not inside a Git work tree. ErrNotRepository = errors.New("coding git changes: workspace is not a repository") // ErrSnapshotExpired means a snapshot is stale, consumed, foreign, or forged. ErrSnapshotExpired = errors.New("coding git changes: snapshot expired") // ErrLimit means a bounded scan, copy, command, or diff budget was exceeded. ErrLimit = errors.New("coding git changes: resource limit exceeded") // ErrGit means a fixed read-only Git command failed. ErrGit = errors.New("coding git changes: git command failed") // ErrClosed means an Inspector was used after Close. ErrClosed = errors.New("coding git changes: inspector closed") )
Functions ¶
This section is empty.
Types ¶
type Changes ¶ added in v0.1.9
Changes is one captured commit diff: the unified diff from a baseline commit to the current worktree, whether the body hit its byte bound, and the complete changed-path list including untracked files.
type Inspector ¶
type Inspector struct {
// contains filtered or unexported fields
}
Inspector owns single-use content baselines for one Workspace.
func New ¶
func New( ws workspace.Workspace, tree *workspace.Tree, policy execution.Policy, executor *execution.Executor, config Config, ) (*Inspector, error)
New constructs a read-only Git change Inspector.
func (*Inspector) Changes ¶
func (i *Inspector) Changes( ctx context.Context, snapshot changes.Snapshot, ) (_ changes.Report, returnErr error)
Changes consumes a Snapshot and reports worktree changes since Capture.
func (*Inspector) CommitChanges ¶ added in v0.1.9
func (i *Inspector) CommitChanges( ctx context.Context, base string, bytes int64, timeout time.Duration, ) (Changes, error)
CommitChanges captures the diff from base to the current worktree plus the complete changed-path list, tracked and untracked alike. The body is bounded by bytes; the path list is read from its own bounded command, so a truncated body never shortens it. Every failure is reported so a caller can render the reference's own sentinel instead of failing its decision.
func (*Inspector) ExcludeLocal ¶
ExcludeLocal adds an anchored path to the repository's local info/exclude. It never modifies the shared .gitignore file.
func (*Inspector) Head ¶ added in v0.1.9
Head resolves the repository's current HEAD commit. It reports ErrNotRepository outside a worktree and ErrGit when Git cannot resolve a commit, so a caller that only wants a best-effort baseline can ignore both.
func (*Inspector) ListWorkspaceFiles ¶
ListWorkspaceFiles returns tracked and non-ignored untracked repository paths in stable order. repository is false only outside a Git worktree.
type Limits ¶
type Limits struct {
Files int
HashBytes int64
CopyBytes int64
DiffFileBytes int64
GitBytes int64
DiffBytes int64
GitTimeout time.Duration
InspectTime time.Duration
}
Limits bounds repository discovery, hashing, baseline copies, and output.
func DefaultLimits ¶
func DefaultLimits() Limits
DefaultLimits returns conservative P0 Git inspection budgets.