submit

package
v0.17.15 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package submit provides functionality for submitting stacked branches as pull requests.

Package submit provides functionality for submitting stacked branches as pull requests.

Package submit provides functionality for submitting stacked branches as pull requests.

Package submit provides functionality for submitting stacked branches as pull requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Action

func Action(ctx *app.Context, opts Options, handler Handler) error

Action performs the submit operation with an event handler for progress feedback.

func GetPRBody

func GetPRBody(branch engine.Branch, editInline bool, existingBody string) (string, error)

GetPRBody gets the PR body, prompting if needed

func GetPRTitle

func GetPRTitle(branch engine.Branch, editInline bool, existingTitle string, scope engine.Scope) (string, error)

GetPRTitle gets the PR title, prompting if needed

func GetReviewers

func GetReviewers(reviewersFlag string) ([]string, []string, error)

GetReviewers gets reviewers from flag or prompts user

func GetReviewersWithPrompt

func GetReviewersWithPrompt(reviewersFlag string) ([]string, []string, error)

GetReviewersWithPrompt gets reviewers, prompting if flag is empty

func HasSubmitWork

func HasSubmitWork(ctx *app.Context, opts Options) (bool, error)

HasSubmitWork reports whether Action might do anything worth showing a progress TUI for. Use this from the CLI to gate TUI initialization — when the answer is no, starting the bubbletea runner only flashes its startup/teardown escape codes and races with the deferred Cleanup before the "no branches to submit" message can render.

Returns true if the target branch is untracked (Action will prompt or print a tracking hint, both of which need the TUI lifecycle to behave), or if there is at least one branch in the resolved scope. Returns false only when the scope is verifiably empty for a tracked target.

func ValidateBranchesToSubmit

func ValidateBranchesToSubmit(ctx *app.Context, branches []string) error

ValidateBranchesToSubmit validates that branches are ready to submit

Types

type BranchInfo

type BranchInfo struct {
	Name     string
	Action   string // "create" or "update"
	PRNumber *int
}

BranchInfo contains information about a branch for submission tracking.

type BranchPlanEvent

type BranchPlanEvent struct {
	BranchName string
	Action     string // "create" or "update"
	IsCurrent  bool
	Skipped    bool
	SkipReason string
}

BranchPlanEvent indicates what will happen to each branch.

type BranchProgressEvent

type BranchProgressEvent struct {
	BranchName string
	Status     BranchStatus
	URL        string // set on success
	Error      error  // set on failure
}

BranchProgressEvent indicates per-branch submission progress.

type BranchStatus

type BranchStatus string

BranchStatus represents the status of a branch during submission.

const (
	StatusPending    BranchStatus = "pending"
	StatusSubmitting BranchStatus = "submitting"
	StatusSyncing    BranchStatus = "syncing"
	StatusDone       BranchStatus = "done"
	StatusError      BranchStatus = "error"
	StatusSkipped    BranchStatus = "skipped"
)

BranchStatus values for tracking submission progress.

type ChannelHandler

type ChannelHandler struct {
	// contains filtered or unexported fields
}

ChannelHandler is a Handler that sends events to a channel. Useful for async consumers like the dashboard.

func NewChannelHandler

func NewChannelHandler(bufferSize int) *ChannelHandler

NewChannelHandler creates a new ChannelHandler with a buffered channel.

func (*ChannelHandler) Close

func (h *ChannelHandler) Close()

Close closes the event channel. Should be called when the action is complete.

func (*ChannelHandler) Confirm

func (h *ChannelHandler) Confirm(_ string, defaultYes bool) (bool, error)

Confirm auto-confirms with the default value. Dashboard operations don't support interactive confirmation.

func (*ChannelHandler) Events

func (h *ChannelHandler) Events() <-chan Event

Events returns the event channel for reading.

func (*ChannelHandler) IsInteractive

func (h *ChannelHandler) IsInteractive() bool

IsInteractive returns false - dashboard/channel handlers are not interactive.

func (*ChannelHandler) OnEvent

func (h *ChannelHandler) OnEvent(e Event)

OnEvent sends the event to the channel. Non-blocking: if the channel is full, the event is dropped.

type CompletionEvent

type CompletionEvent struct {
	Success bool
	Message string // "All PRs up to date", "Dry run complete", etc.
}

CompletionEvent indicates the action has finished.

type Event

type Event interface {
	// contains filtered or unexported methods
}

Event represents a feedback event from the submit action. Implementations should use type switches to handle specific event types.

type Handler

type Handler interface {
	// OnEvent is called for each event during submission.
	// Handlers should use type switches to handle specific event types.
	OnEvent(event Event)

	// Confirm prompts for user confirmation when the --confirm flag is used.
	// Returns (confirmed, error).
	// Non-interactive handlers should return (defaultYes, nil).
	Confirm(message string, defaultYes bool) (bool, error)

	// IsInteractive returns true if the handler supports interactive prompts.
	// Used to determine whether to prompt for actions like tracking untracked branches.
	IsInteractive() bool
}

Handler receives events from the submit action and handles user interaction. Implementations should handle events appropriately for their UI context (interactive terminal, non-interactive, dashboard, etc.)

type Info

type Info struct {
	BranchName string
	Head       string
	Base       string
	HeadSHA    string
	BaseSHA    string
	Action     string // "create" or "update"
	PRNumber   *int
	Metadata   *PRMetadata
}

Info contains information about a branch to submit

type MetadataOptions

type MetadataOptions struct {
	Edit              bool
	EditTitle         bool
	EditDescription   bool
	NoEdit            bool
	NoEditTitle       bool
	NoEditDescription bool
	Draft             bool
	Publish           bool
	Reviewers         string
	ReviewersPrompt   bool
	// Config-driven options
	ConfigDraft     bool     // Default draft mode from config (used for new PRs)
	ConfigReviewers []string // Default reviewers from config
	ConfigLabels    []string // Default labels from config
	ConfigAssignees []string // Default assignees from config
}

MetadataOptions contains options for PR metadata collection

type Options

type Options struct {
	Branch               string
	StackRange           engine.StackRange
	Force                bool
	DryRun               bool
	Confirm              bool
	UpdateOnly           bool
	Always               bool
	Restack              bool
	Draft                bool
	Publish              bool
	Edit                 bool
	EditTitle            bool
	EditDescription      bool
	NoEdit               bool
	NoEditTitle          bool
	NoEditDescription    bool
	Reviewers            string
	TeamReviewers        string
	MergeWhenReady       bool
	RerequestReview      bool
	View                 bool
	Web                  bool
	Comment              string
	TargetTrunk          string
	IgnoreOutOfSyncTrunk bool
	SubmitFooter         bool // Whether to include PR footer (from config)
	NoLabels             bool // Skip applying default labels from config
	NoAssignees          bool // Skip applying default assignees from config

	// Config-driven options (these are merged with flags)
	ConfigDraft     bool     // Default draft mode from config
	ConfigWeb       string   // When to open browser from config (always/created/never)
	ConfigLabels    []string // Default labels from config
	ConfigReviewers []string // Default reviewers from config
	ConfigAssignees []string // Default assignees from config
}

Options contains options for the submit command

type PRMetadata

type PRMetadata struct {
	Title         string
	Body          string
	IsDraft       bool
	Reviewers     []string
	TeamReviewers []string
	Labels        []string // Labels to apply to the PR
	Assignees     []string // Assignees to apply to the PR
}

PRMetadata contains PR metadata

func PreparePRMetadata

func PreparePRMetadata(branch engine.Branch, opts MetadataOptions, ctx *app.Context) (*PRMetadata, error)

PreparePRMetadata prepares PR metadata for a branch

type PreparingEvent

type PreparingEvent struct{}

PreparingEvent indicates the preparation/validation phase has started.

type RestackEvent

type RestackEvent struct {
	Started   bool
	Completed bool
}

RestackEvent indicates restack phase status.

type StackDisplayEvent

type StackDisplayEvent struct {
	Stack       *tree.StackTree   // tree structure for rendering the stack
	FixedMap    map[string]bool   // branch -> is fixed (doesn't need restack)
	ScopeMap    map[string]string // branch -> scope
	WorktreeMap map[string]string // branch -> worktree path (only for stack roots with managed worktrees)
}

StackDisplayEvent indicates the initial stack visualization phase. Handlers can use this to display the branches that will be processed.

type SubmissionStartEvent

type SubmissionStartEvent struct {
	Branches     []BranchInfo
	IsSequential bool // Sequential submission mode (all creates) for PR ordering
}

SubmissionStartEvent indicates the submission phase is beginning.

Jump to

Keyboard shortcuts

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