Documentation
¶
Overview ¶
Package branchflags finds the branch a command works in: -b, -p, and --pr (BranchFlags), an authoring command's -b or --new (BranchChoice), the question where several branches change a port, and a run command's named or latest check. It imports no verb (part 4, item 2).
Index ¶
- Constants
- func LatestOf(ctx context.Context, e *engine.Engine, streams term.Streams, where BranchFlags, ...) (model.Run, error)
- func NamedOrLatest(ctx context.Context, e *engine.Engine, streams term.Streams, where BranchFlags, ...) (model.Run, error)
- func NextIn(ctx context.Context, e *engine.Engine, branch model.Branch, steps ...string) string
- func StartFor(ctx context.Context, e *engine.Engine, port string, work engine.Work) (model.Branch, bool, error)
- type BranchChoice
- type BranchFlags
- type ChosenBranch
Constants ¶
const NewNamed = "\x00"
NewNamed is --new given without a name: the branch is named for the port, or the version an update moves to.
Variables ¶
This section is empty.
Functions ¶
func LatestOf ¶
func LatestOf(ctx context.Context, e *engine.Engine, streams term.Streams, where BranchFlags, unnamed string) (model.Run, error)
LatestOf is the latest check of the branch the flags name, else of the one checked out here.
func NamedOrLatest ¶
func NamedOrLatest(ctx context.Context, e *engine.Engine, streams term.Streams, where BranchFlags, args []string, unnamed string) (model.Run, error)
NamedOrLatest is the check args name, or with none, the latest check of the branch -b, -p, or --pr names, else of the one checked out here: a branch has one check at a time, so it is the one queued or running, if any is (the second look's §3). unnamed says what to do elsewhere.
func NextIn ¶
NextIn is a Next: line's steps, run in a branch: as they are where it's checked out, and after a cd into its worktree elsewhere, since a check from outside takes its committed head, not its edits. A Next: names only what would be accepted (the release bar's rule), so the branch's steps run where the branch is.
Types ¶
type BranchChoice ¶
type BranchChoice struct {
Branch string
// New is --new's name, or newNamed where it named none; empty where
// --new wasn't given.
New string
}
BranchChoice is the branch an authoring command was pointed at.
func (BranchChoice) IsNew ¶
func (c BranchChoice) IsNew() bool
IsNew is whether --new was given; newName is the name it gave, if any.
func (BranchChoice) NewName ¶
func (c BranchChoice) NewName() string
func (*BranchChoice) Register ¶
func (c *BranchChoice) Register(cmd *cobra.Command)
Register adds -b and --new, one at a time, to an authoring command.
type BranchFlags ¶
BranchFlags are how a command about a whole branch is told which (the command-line UX review's §1, revised): -b its exact name, -p the port it changes, or --pr the pull request it tracks; with none of them, the branch checked out here. Each flag has one meaning, so a port's name and a branch's never collide, and none is a positional argument.
func (BranchFlags) Explicit ¶
func (b BranchFlags) Explicit() bool
Explicit says whether a flag named the branch, rather than where the command runs.
func (*BranchFlags) Register ¶
Register adds the flags to a command, -b with completion of the open branches' names.
func (BranchFlags) Resolve ¶
func (b BranchFlags) Resolve(ctx context.Context, e *engine.Engine, streams term.Streams) (model.Branch, error)
Resolve finds the branch the flags name, else the one checked out here. A port one open branch changes names it, said on the first line; one several change is asked about on a terminal and refused in a script, with their exact names. A flag beats where the command runs, and says so where the two differ.
type ChosenBranch ¶
ChosenBranch is the branch an authoring command works in, and whether it was started for it; or, for forVersion, none yet: an update starts it, named for the version it finds.
func ChooseBranch ¶
func ChooseBranch(ctx context.Context, e *engine.Engine, streams term.Streams, where BranchChoice, port string, work engine.Work) (ChosenBranch, error)
ChooseBranch is the branch an authoring command works in, as engine.Select finds it: -b's, an existing one; one --new starts; the one checked out here; or the port's own open branch, one started for it where none changes it, said first. Where several change it, a terminal is asked once which, or for a new one, and a script is told them.
func SettleSelection ¶
func SettleSelection(ctx context.Context, e *engine.Engine, streams term.Streams, selection engine.Selection, port string, work engine.Work, say bool) (ChosenBranch, error)
SettleSelection takes a selection: the branch found, said where it was chosen for the port; the one to start, started, or for an update left for it to start; or the choices, asked about once, a new branch among them where the work may start one (the split's 7d row 7: the two questions, "start another?" and "which one?", as one), and refused in a script. A new branch chosen is the one Select starts for --new. say is a command with --new where it wasn't given, which says the branch it starts, and that --new starts another.