Documentation
¶
Overview ¶
Package git provides bounded, read-only repository inspection.
Index ¶
- Constants
- Variables
- func ChangedFiles(ctx context.Context, root, base, head string) ([]string, error)
- func CommonDir(ctx context.Context, root string) (string, error)
- func DefaultBranch(ctx context.Context, root string) string
- func Files(ctx context.Context, root, ref string) ([]string, error)
- func Identity(ctx context.Context, root string) string
- func IsAncestor(ctx context.Context, root, base, head string) (bool, error)
- func MergeBase(ctx context.Context, root, a, b string) (string, error)
- func ReadBlob(ctx context.Context, root, oid string) ([]byte, error)
- func ReadFile(ctx context.Context, root, ref, path string) ([]byte, error)
- func Resolve(ctx context.Context, root, ref string) (string, error)
- func WorkingFiles(ctx context.Context, root string) ([]string, error)
- func WorktreeBranches(ctx context.Context, root string) ([]string, error)
- type BlobReader
- type Info
- type TreeEntry
- type WorktreeStatus
Constants ¶
const MaxFileBytes = 4 << 20
MaxFileBytes bounds a single file or small command output.
const NullPath = "/dev/null"
command binds every operation to the explicit root and object database. NullPath is the empty config/attributes path for Git. os.DevNull is "NUL" on Windows, which Git for Windows rejects; it maps "/dev/null" itself.
Variables ¶
var ErrBlobTooLarge = errors.New("Git blob exceeds read limit")
ErrBlobTooLarge reports a blob above the caller's read limit.
Functions ¶
func ChangedFiles ¶
ChangedFiles lists paths that differ between base and head. head may be WORKTREE, which includes staged, unstaged and untracked non-ignored files. Renames are reported as both the old and the new path.
func DefaultBranch ¶
DefaultBranch guesses the integration base: the local counterpart of origin/HEAD, then main, master or trunk. It returns "" when none exists.
func Identity ¶
Identity returns a location-independent repository identity derived from its root commits, shared by every clone and worktree. It returns "" when the directory is not a Git repository with history.
func IsAncestor ¶
IsAncestor checks history without changing refs or relying on mutable branch names.
func WorkingFiles ¶
WorkingFiles lists tracked and untracked, non-ignored files below root, relative to root. It respects .gitignore and Git exclude settings.
Types ¶
type BlobReader ¶
type BlobReader struct {
// contains filtered or unexported fields
}
BlobReader streams many objects through one `git cat-file --batch` process instead of spawning a subprocess per file.
func OpenBlobReader ¶
func OpenBlobReader(ctx context.Context, root string) (*BlobReader, error)
OpenBlobReader starts a batch reader bound to ctx; Close releases it.
type Info ¶
type WorktreeStatus ¶
type WorktreeStatus struct {
Path string `json:"path"`
Branch string `json:"branch,omitempty"`
Commit string `json:"commit"`
Detached bool `json:"detached"`
Staged []string `json:"staged"`
Unstaged []string `json:"unstaged"`
Untracked []string `json:"untracked"`
InspectionError string `json:"inspection_error,omitempty"`
CommitIncluded bool `json:"commit_included"`
UncommittedIncluded bool `json:"uncommitted_included"`
}
WorktreeStatus is a read-only boundary observation. Dirty files never enter committed integration candidates; ignored files are not enumerated.
func InspectWorktrees ¶
func InspectWorktrees(ctx context.Context, root string) ([]WorktreeStatus, error)