Documentation
¶
Overview ¶
Eager per-write git checkpoint
Error formatting ¶
Filesystem helpers ¶
Git workflow-artifact exclusion ¶
Local context: typed values carried on an explicit context.Context, the native propagation mechanism across goroutines.
Named schema error ¶
Process helpers ¶
Record predicate.
Index ¶
- Constants
- Variables
- func CaptureStack() string
- func Contains(parent, child string) bool
- func DisableEagerCommit()
- func EagerCommit(ctx context.Context, options EagerCommitOptions)
- func EnsureSeniorDevExcluded(ctx context.Context, workspace string) (bool, error)
- func ErrorData(value any) map[string]any
- func ErrorFormat(value any) string
- func ErrorMessage(value any) string
- func Exists(path string) bool
- func FileMimeType(path string) string
- func FindUp(targets []string, start string, stop string, options ...FindUpOptions) []string
- func GeneratedRunPath(path string) bool
- func GitArgv(args ...string) []string
- func GlobUp(pattern, start, stop string) []string
- func IgnoredAtStart(path string) bool
- func InitialIgnoredPaths() ([]string, error)
- func InitialInputs() (gitidentity.Inputs, error)
- func InputLeftAlone(root, relative string) bool
- func IsDir(path string) bool
- func IsRecord(value any) bool
- func NormalizePath(path string) string
- func NormalizePathPattern(path string) string
- func Overlaps(a, b string) bool
- func PathIgnoredAtStart(path string, paths []string) bool
- func ProcessLines(ctx context.Context, command []string, options ...RunOptions) ([]string, error)
- func ReadBytes(path string) ([]byte, error)
- func ReadJSON(path string, dst any) error
- func ReadText(path string) (string, error)
- func ResolvePath(path string) (string, error)
- func Size(path string) int64
- func Stat(path string) (os.FileInfo, bool)
- func StatAsync(path string) (os.FileInfo, bool, error)
- func StopProcess(ctx context.Context, child *Child)
- func Up(targets []string, start, stop string) []string
- func WindowsPath(path string) string
- func Write(path string, content []byte, mode ...fs.FileMode) error
- func WriteJSON(path string, data any, mode ...fs.FileMode) error
- func WriteStream(path string, stream io.Reader, mode ...fs.FileMode) error
- func WriteText(path, content string, mode ...fs.FileMode) error
- type Child
- type ContextNotFound
- type EagerCommitOptions
- type FindUpOptions
- type LocalContext
- type NamedErrorFactory
- type NamedSchemaError
- type ProcessOptions
- type ProcessResult
- type RunFailedError
- type RunOptions
- type StackError
- type TextResult
Constants ¶
const ( CommitterName = gitidentity.EngineName CommitterEmail = gitidentity.EngineEmail )
The values live in internal/gitidentity, which codeaf's own side of a run reads on every platform.
const GeneratedRunPaths = gitidentity.GeneratedRunPaths
GeneratedRunPaths and GeneratedRunPath are internal/gitidentity's, where codeaf's own side of a run reads them on every platform.
Variables ¶
var ExcludedPaths = []string{
".senior-dev/",
}
Functions ¶
func CaptureStack ¶
func CaptureStack() string
CaptureStack provides a convenient StackError stack for callers that need ErrorFormat's stack branch.
func DisableEagerCommit ¶
func DisableEagerCommit()
DisableEagerCommit turns off the per-write checkpoint for the rest of the process. A run whose recorder keeps its own snapshots does not want commits in the workspace -- under --in-place that workspace may be a repository the run has no business writing history into. Call it before the run starts.
func EagerCommit ¶
func EagerCommit(ctx context.Context, options EagerCommitOptions)
func EnsureSeniorDevExcluded ¶
EnsureSeniorDevExcluded adds senior-dev's own folder to the exclude file git reads for workspace, once.
THE FILE IS THE ONE GIT READS, which is not always <git-dir>/info/exclude. In a linked worktree the git dir is .git/worktrees/<name>, and git ignores an info/ folder there in favour of the common dir's. An exclude written beside the git dir changed nothing: `.senior-dev/` stayed untracked, and a commit of the tree's own status would have taken senior-dev's database, spec and tool logs with it. `rev-parse --git-path` names the file git actually consults, which for a linked worktree is the repository's shared one.
func ErrorFormat ¶
func ErrorMessage ¶
func FileMimeType ¶
func FindUp ¶
func FindUp(targets []string, start string, stop string, options ...FindUpOptions) []string
func GeneratedRunPath ¶
func IgnoredAtStart ¶
IgnoredAtStart reads the parent's frozen ignore list. It is a small file in the run record, since ignored directories can contain thousands of files.
func InitialIgnoredPaths ¶
InitialIgnoredPaths reads the one list codeaf captured before the run.
func InitialInputs ¶
func InitialInputs() (gitidentity.Inputs, error)
InitialInputs reads the list of inputs codeaf copied into the run's copy, with their fingerprints; none for a run started any other way.
func InputLeftAlone ¶
InputLeftAlone says relative is one of the person's untracked files codeaf copied in as an input and this write left it as it was, so it is not the run's work and is never staged (gitidentity's inputs.go): staging it would write it into git's object store. An unreadable list never permits the commit, as an unreadable ignore list does not.
func NormalizePath ¶
func NormalizePathPattern ¶
func PathIgnoredAtStart ¶
PathIgnoredAtStart matches a file or a child of an ignored directory.
func ProcessLines ¶
func ResolvePath ¶
func StopProcess ¶
func WindowsPath ¶
Types ¶
type Child ¶
type Child struct {
Cmd *exec.Cmd
Stdin io.WriteCloser
Stdout io.ReadCloser
Stderr io.ReadCloser
Exited <-chan int
// contains filtered or unexported fields
}
func SpawnProcess ¶
type ContextNotFound ¶
type ContextNotFound struct{ Name string }
func (*ContextNotFound) Error ¶
func (e *ContextNotFound) Error() string
type EagerCommitOptions ¶
type FindUpOptions ¶
type FindUpOptions struct {
RootFirst bool
}
type LocalContext ¶
func CreateLocalContext ¶
func CreateLocalContext[T any](name string) *LocalContext[T]
func (*LocalContext[T]) MustUse ¶
func (l *LocalContext[T]) MustUse(ctx context.Context) T
type NamedErrorFactory ¶
type NamedErrorFactory struct {
Tag string
}
func NamedSchemaErrorFactory ¶
func NamedSchemaErrorFactory(tag string) NamedErrorFactory
func (NamedErrorFactory) IsInstance ¶
func (f NamedErrorFactory) IsInstance(value any) bool
func (NamedErrorFactory) New ¶
func (f NamedErrorFactory) New(data map[string]any, cause ...error) *NamedSchemaError
type NamedSchemaError ¶
type NamedSchemaError struct {
Name string `json:"name"`
Data map[string]any `json:"data"`
Cause error `json:"-"`
}
func (*NamedSchemaError) Error ¶
func (e *NamedSchemaError) Error() string
func (*NamedSchemaError) ToObject ¶
func (e *NamedSchemaError) ToObject() map[string]any
func (*NamedSchemaError) Unwrap ¶
func (e *NamedSchemaError) Unwrap() error
type ProcessOptions ¶
type ProcessResult ¶
type ProcessResult struct {
Code int `json:"code"`
Stdout []byte `json:"-"`
Stderr []byte `json:"-"`
}
func RunProcess ¶
func RunProcess(ctx context.Context, command []string, options ...RunOptions) (ProcessResult, error)
type RunFailedError ¶
func (*RunFailedError) Error ¶
func (e *RunFailedError) Error() string
func (*RunFailedError) ErrorName ¶
func (e *RunFailedError) ErrorName() string
type RunOptions ¶
type RunOptions struct {
ProcessOptions
NoThrow bool
}
type StackError ¶
StackError may supply a pre-recorded stack trace.
type TextResult ¶
type TextResult struct {
ProcessResult
Text string `json:"text"`
}
func TextProcess ¶
func TextProcess(ctx context.Context, command []string, options ...RunOptions) (TextResult, error)