Documentation
¶
Overview ¶
Package decide holds the branch and env decisions the create-like flows share.
Index ¶
- Constants
- func ApplyFastForward(ctx context.Context, params ApplyFastForwardParams) (proceed bool)
- func BranchCandidates(ctx context.Context, projectDir string) []domain.BranchCandidate
- func EnvOptions(strategy domain.EnvStrategy) []flow.Option
- func EnvParentFallback(ctx context.Context, params EnvFallbackParams) (bool, string)
- func IsolationOptions(params IsolationOptionsParams) []flow.Option
- func KeptSourceLines(answers flow.Answers, key string) []string
- func MemoizedTarget(ctx context.Context, projectDir string) func(string) domain.BranchTarget
- func Origins(params OriginsParams) map[string]domain.AnswerOrigin
- func Pick(params PickParams) string
- func Remember(ctx context.Context, params RememberParams)
- func SourceUpdateStep(params SourceUpdateStepParams) flow.Step
- func WarnUnseenFallback(ctx context.Context, params UnseenFallbackParams) []string
- type ApplyFastForwardParams
- type EnvFallbackParams
- type IsolationOptionsParams
- type OriginsParams
- type PickParams
- type RememberParams
- type SourceUpdateParams
- type SourceUpdatePrompt
- type SourceUpdateStepParams
- type UnseenFallbackParams
Constants ¶
const ( UpdateFastForward = domain.SourceUpdateFastForward UpdateKeep = domain.SourceUpdateKeep )
UpdateFastForward and UpdateKeep answer a source-update step.
Variables ¶
This section is empty.
Functions ¶
func ApplyFastForward ¶ added in v0.29.0
func ApplyFastForward(ctx context.Context, params ApplyFastForwardParams) (proceed bool)
ApplyFastForward runs an accepted fast-forward. Unattended (--ff) it is best effort: a branch that cannot be cleanly fast-forwarded is left as-is and the run proceeds from it. Interactively a failure asks whether to go on from the stale branch; proceed is false when that is declined.
func BranchCandidates ¶
func BranchCandidates(ctx context.Context, projectDir string) []domain.BranchCandidate
func EnvOptions ¶ added in v0.29.0
func EnvOptions(strategy domain.EnvStrategy) []flow.Option
EnvOptions are the env strategies a create-like run offers, the config's own first and answered by the empty value.
func EnvParentFallback ¶
func EnvParentFallback(ctx context.Context, params EnvFallbackParams) (bool, string)
EnvParentFallback: the "parent" strategy silently sources .env from the main worktree when the source branch has no local one.
func IsolationOptions ¶ added in v0.29.0
func IsolationOptions(params IsolationOptionsParams) []flow.Option
func KeptSourceLines ¶ added in v0.30.0
KeptSourceLines names a source left behind origin by a remembered or to-be-remembered "keep": asked, it is a visible choice; settled from memory, it would otherwise leave no trace in the recap.
func MemoizedTarget ¶
MemoizedTarget caches branch classification for one run: it costs ~3 git subprocesses, and a step, a recap and a warning all classify the same name.
func Origins ¶ added in v0.30.0
func Origins(params OriginsParams) map[string]domain.AnswerOrigin
Origins says, per memory id, what settled each answer a step could have remembered, for the JSON a script reads to know whether a remembered answer stood in for a flag it did not pass.
func Pick ¶ added in v0.29.0
func Pick(params PickParams) string
func Remember ¶ added in v0.30.0
func Remember(ctx context.Context, params RememberParams)
Remember keeps what a confirmed session ticked. Failing to write it costs the next run a question, never this run its worktree.
func SourceUpdateStep ¶ added in v0.29.0
func SourceUpdateStep(params SourceUpdateStepParams) flow.Step
SourceUpdateStep applies only to a behind-only branch; a diverged one is not a gate here, it becomes a ⚠ line in the recap.
func WarnUnseenFallback ¶ added in v0.29.0
func WarnUnseenFallback(ctx context.Context, params UnseenFallbackParams) []string
WarnUnseenFallback says after the fact what a recap warns an interactive run about: an unattended one never saw it, and its .env came from main rather than from the parent it named.
Types ¶
type ApplyFastForwardParams ¶ added in v0.29.0
type EnvFallbackParams ¶
type IsolationOptionsParams ¶ added in v0.29.0
type OriginsParams ¶ added in v0.30.0
type OriginsParams struct {
Context flow.Context
Answers flow.Answers
EnvKey string
IsolationKey string
SourceUpdateKey string
EnvFlag bool
IsolationFlag bool
FastForward bool
}
OriginsParams names the steps of a session creating a worktree, and the flags its request carried; an empty key is a question the session does not ask.
type PickParams ¶ added in v0.29.0
type RememberParams ¶ added in v0.30.0
type SourceUpdateParams ¶
type SourceUpdatePrompt ¶
type SourceUpdatePrompt struct {
Branch string
Show bool
Title string
Description string
Warning string
// AbortOnDecline distinguishes a diverged branch (declining cancels) from a
// fast-forward offer (declining proceeds as-is).
AbortOnDecline bool
SkipReason string
}
func SourceUpdate ¶
func SourceUpdate(ctx context.Context, params SourceUpdateParams) SourceUpdatePrompt
SourceUpdate classifies the divergence from origin of whichever branch the worktree starts from: the target branch when it already exists locally (its commits are what gets checked out), its origin counterpart when it exists only there, the source branch otherwise.
type SourceUpdateStepParams ¶ added in v0.29.0
type SourceUpdateStepParams struct {
Key string
Prompt func(flow.Answers) SourceUpdatePrompt
FastForward bool
}
type UnseenFallbackParams ¶ added in v0.29.0
type UnseenFallbackParams struct {
Fallback EnvFallbackParams
Prompter flow.Prompter
Presenter flow.Presenter
}