Help us shape the future of Go! Take the 2026 Go Developer Survey

decide

package
v0.30.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package decide holds the branch and env decisions the create-like flows share.

Index

Constants

View Source
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

func KeptSourceLines(answers flow.Answers, key string) []string

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

func MemoizedTarget(ctx context.Context, projectDir string) func(string) domain.BranchTarget

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 ApplyFastForwardParams struct {
	ProjectDir string
	Subject    string
	Many       bool
	Prompter   flow.Prompter
	Presenter  flow.Presenter
}

type EnvFallbackParams

type EnvFallbackParams struct {
	ProjectDir  string
	Source      string
	Config      domain.Config
	EnvOverride string
}

type IsolationOptionsParams added in v0.29.0

type IsolationOptionsParams struct {
	First domain.Isolation
	Many  bool
}

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 PickParams struct {
	Many    bool
	One     string
	Several string
}

type RememberParams added in v0.30.0

type RememberParams struct {
	Context   flow.Context
	Session   flow.Session
	Answers   flow.Answers
	Presenter flow.Presenter
}

type SourceUpdateParams

type SourceUpdateParams struct {
	ProjectDir string
	Target     func(string) domain.BranchTarget
	Branch     string
	Source     string
	Many       bool
}

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL