Documentation
¶
Overview ¶
Package changes defines the application boundary for read-only workspace change attribution. Concrete adapters live in subpackages; this package deliberately contains no process execution.
Index ¶
- Variables
- func CountUnifiedDiffLines(diff string) (additions, deletions int)
- type Branch
- type DiffSection
- type DiffSummary
- type Entry
- type Inspector
- type Kind
- type PathState
- type Report
- type Snapshot
- type StatusEntry
- type WorktreeInspector
- type WorktreeStatus
- func (s WorktreeStatus) Branch() Branch
- func (s WorktreeStatus) Entries() []StatusEntry
- func (s WorktreeStatus) ProtectedOmitted() int
- func (s WorktreeStatus) Repository() bool
- func (s WorktreeStatus) Staged() DiffSection
- func (s WorktreeStatus) Unstaged() DiffSection
- func (s WorktreeStatus) Untracked() DiffSection
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("coding changes: invalid value")
ErrInvalid means a snapshot or report violates the change contract.
Functions ¶
func CountUnifiedDiffLines ¶
CountUnifiedDiffLines counts added and deleted content lines inside unified diff hunks. File headers and no-newline markers are not content changes.
Types ¶
type Branch ¶
type Branch struct {
Head string
OID string
Upstream string
Ahead int
Behind int
Detached bool
Unborn bool
}
Branch describes the current repository head without resolving or changing refs.
type DiffSection ¶
type DiffSection struct {
Summary DiffSummary
Diff string
Truncated bool
}
DiffSection is one immutable-by-convention staged, unstaged, or untracked presentation payload.
type DiffSummary ¶
DiffSummary is a bounded section's aggregate.
type Inspector ¶
type Inspector interface {
Capture(context.Context) (Snapshot, error)
Changes(context.Context, Snapshot) (Report, error)
}
Inspector captures an opaque baseline and later reports changes relative to it. Implementations own the snapshot format and must remain read-only.
type PathState ¶
type PathState string
PathState is one Git index or worktree status column.
const ( PathUnchanged PathState = "" PathAdded PathState = "added" PathModified PathState = "modified" PathDeleted PathState = "deleted" PathRenamed PathState = "renamed" PathCopied PathState = "copied" PathTypeChanged PathState = "type_changed" PathUnmerged PathState = "unmerged" PathUntracked PathState = "untracked" )
Normalized Git path states.
type Report ¶
type Report struct {
// contains filtered or unexported fields
}
Report is an immutable-by-API change list and optional bounded diff.
func (Report) Summary ¶
func (r Report) Summary() DiffSummary
Summary returns aggregate file and visible unified-diff line counts.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is immutable opaque state produced and consumed by one Inspector implementation. Format versions the private payload.
func NewSnapshot ¶
NewSnapshot returns a defensively copied inspector snapshot.
type StatusEntry ¶
type StatusEntry struct {
Path string
PreviousPath string
Index PathState
Worktree PathState
Conflict bool
Submodule string
}
StatusEntry preserves Git's separate index and worktree columns.
type WorktreeInspector ¶
type WorktreeInspector interface {
Status(context.Context) (WorktreeStatus, error)
}
WorktreeInspector reports bounded point-in-time repository truth. It is deliberately separate from Inspector, whose reports attribute changes to one interaction baseline.
type WorktreeStatus ¶
type WorktreeStatus struct {
// contains filtered or unexported fields
}
WorktreeStatus is a clone-safe point-in-time repository snapshot.
func NewWorktreeStatus ¶
func NewWorktreeStatus( repository bool, branch Branch, entries []StatusEntry, staged, unstaged, untracked DiffSection, protectedOmitted int, ) (WorktreeStatus, error)
NewWorktreeStatus validates and defensively copies a repository snapshot.
func (WorktreeStatus) Branch ¶
func (s WorktreeStatus) Branch() Branch
Branch returns the captured branch state.
func (WorktreeStatus) Entries ¶
func (s WorktreeStatus) Entries() []StatusEntry
Entries returns a defensive copy of changed paths.
func (WorktreeStatus) ProtectedOmitted ¶
func (s WorktreeStatus) ProtectedOmitted() int
ProtectedOmitted reports hidden product-metadata paths.
func (WorktreeStatus) Repository ¶
func (s WorktreeStatus) Repository() bool
Repository reports whether the workspace is inside a Git work tree.
func (WorktreeStatus) Staged ¶
func (s WorktreeStatus) Staged() DiffSection
Staged returns the bounded index diff.
func (WorktreeStatus) Unstaged ¶
func (s WorktreeStatus) Unstaged() DiffSection
Unstaged returns the bounded worktree diff.
func (WorktreeStatus) Untracked ¶
func (s WorktreeStatus) Untracked() DiffSection
Untracked returns bounded previews of untracked text files.