pushflow

package
v0.13.2 Latest Latest
Warning

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

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

Documentation

Overview

Package pushflow implements the shared "offer to push a branch after the action" step used by issue close, commit, and the review lifecycle commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlags

func AddFlags(cmd *cobra.Command)

AddFlags registers --push and --no-push on cmd. Call from each command that offers the push proposal.

func Propose

func Propose(ctx context.Context, c Pusher, opts Opts, confirm ConfirmFunc) error

Propose runs the preview → confirm → push step. It returns nil on every skip path (gated off, no remote, nothing to push, unreachable remote, declined). A confirmed push that fails returns the wrapped git error; the caller's already-completed action is not rolled back.

func ReadFlags

func ReadFlags(cmd *cobra.Command) (push, noPush bool)

ReadFlags reads --push/--no-push from cmd. Missing flags read as false, so it is safe to call from a shared deps builder used by commands that did not add the flags. Mutual exclusion is enforced later by ResolveFlags.

func ResolveFlags

func ResolveFlags(push, noPush, propose bool) (skip, autoConfirm bool, err error)

ResolveFlags combines the --push/--no-push flags with the config master switch into the (skip, autoConfirm) decision. The two flags are mutually exclusive.

Types

type ConfirmFunc

type ConfirmFunc func(ctx context.Context, summary string) (bool, error)

ConfirmFunc asks the operator to confirm the push. Production uses a huh form (NewHuhConfirm); tests inject a stub.

func NewHuhConfirm

func NewHuhConfirm() ConfirmFunc

NewHuhConfirm returns the production ConfirmFunc: a huh confirm whose default selection is Yes (the push is the expected outcome of an opt-in flow).

type Opts

type Opts struct {
	Branch         string // branch to push
	Skip           bool   // --no-push or config push.propose=false
	AutoConfirm    bool   // --push: push without prompting
	NonInteractive bool   // -y / no TTY: skip unless AutoConfirm

	// Merge-vs-parent preview (commit). When IncludeMergePreview is true and
	// Parent is a non-empty branch/ref distinct from Branch, Propose prints how
	// Branch would merge into Parent (fast-forward / merge commit / conflicts /
	// already merged) alongside the push preview.
	IncludeMergePreview bool
	Parent              string
}

Opts configures one Propose call.

type Pusher

type Pusher interface {
	Remote() (string, error)
	PushDryRun(ctx context.Context, branch string) (git.PushOutcome, bool, error)
	PushBranch(ctx context.Context, branch string) error
	IsAncestor(ctx context.Context, child, ancestor string) (bool, error)
	MergeDryRun(ctx context.Context, branchName, baseBranch string) ([]string, error)
	IO() *pkg.IO
}

Pusher is the slice of *git.Client the proposal step needs.

Jump to

Keyboard shortcuts

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