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 ¶
- func Action(ctx *app.Context, opts Options, handler Handler) error
- func GetPRBody(branch engine.Branch, editInline bool, existingBody string) (string, error)
- func GetPRTitle(branch engine.Branch, editInline bool, existingTitle string, ...) (string, error)
- func GetReviewers(reviewersFlag string) ([]string, []string, error)
- func GetReviewersWithPrompt(reviewersFlag string) ([]string, []string, error)
- func ValidateBranchesToSubmit(ctx *app.Context, branches []string) ([]string, error)
- type BranchInfo
- type BranchPlanEvent
- type BranchProgressEvent
- type BranchStatus
- type BranchWarningEvent
- type ChannelHandler
- type CompletionEvent
- type CompletionOutcome
- type Event
- type Handler
- type Info
- type JSONBranchResult
- type JSONHandler
- type JSONResult
- type MetadataOptions
- type Options
- type PRMetadata
- type PlanningCompleteEvent
- type PreparingEvent
- type RestackEvent
- type StackDisplayEvent
- type StackSnapshot
- type SubmissionStartEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
GetReviewers gets reviewers from flag or prompts user
func GetReviewersWithPrompt ¶
GetReviewersWithPrompt gets reviewers, prompting if flag is empty
func ValidateBranchesToSubmit ¶
ValidateBranchesToSubmit validates that branches are ready to submit and returns the submittable subset. Branches that are not restacked on their in-submission parent (or whose base no longer matches an out-of-submission parent remotely) are pruned together with their descendants, with a warning per pruned subtree, so the rest of the stack still submits. An error is returned only when nothing in scope is submittable.
Types ¶
type BranchInfo ¶
type BranchInfo struct {
Name string
Action engine.SubmitAction
PRNumber *int
}
BranchInfo contains information about a branch for submission tracking.
type BranchPlanEvent ¶
type BranchPlanEvent struct {
BranchName string
Action engine.SubmitAction
PRNumber *int // existing PR number for updates, nil for creates
IsCurrent bool
Empty bool // branch has no commits relative to its parent
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 BranchWarningEvent ¶ added in v0.22.0
BranchWarningEvent surfaces a non-fatal warning raised while submitting a branch (e.g. labels or reviewers could not be applied). Warnings must flow through the handler rather than direct console output: the interactive runner quiets the console while the TUI is active, so direct writes during the submission phase are silently dropped.
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 {
Outcome CompletionOutcome
Message string // human-readable detail, e.g. "All PRs up to date"
Duration time.Duration // elapsed run time; set when branches were submitted
}
CompletionEvent indicates the action has finished.
func (CompletionEvent) Success ¶
func (e CompletionEvent) Success() bool
Success reports whether the run ended without failure or cancellation.
type CompletionOutcome ¶ added in v0.22.0
type CompletionOutcome string
CompletionOutcome classifies how a submit run ended, so handlers can decide presentation without string-matching messages.
const ( OutcomeComplete CompletionOutcome = "complete" // branches were submitted OutcomeUpToDate CompletionOutcome = "up-to-date" // nothing needed submitting OutcomeDryRun CompletionOutcome = "dry-run" // plan reported, nothing submitted OutcomeCanceled CompletionOutcome = "canceled" // user declined a confirmation OutcomeNothingToSubmit CompletionOutcome = "nothing-to-submit" // no branches in scope / untracked OutcomeOnTrunk CompletionOutcome = "on-trunk" // checked out on trunk; nothing to submit from here OutcomeFailed CompletionOutcome = "failed" // at least one branch failed )
CompletionOutcome values.
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 engine.SubmitAction
PRNumber *int
Metadata *PRMetadata
}
Info contains information about a branch to submit
type JSONBranchResult ¶ added in v0.22.0
type JSONBranchResult struct {
Branch string `json:"branch"`
Action string `json:"action,omitempty"` // "create" or "update"
Status string `json:"status"` // pending, done, error, skipped
PR *int `json:"pr,omitempty"`
URL string `json:"url,omitempty"`
SkipReason string `json:"skip_reason,omitempty"`
Error string `json:"error,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
JSONBranchResult is one branch's plan and result in submit JSON output.
type JSONHandler ¶ added in v0.22.0
type JSONHandler struct {
Result *JSONResult
// contains filtered or unexported fields
}
JSONHandler collects submit events into a JSONResult.
func NewJSONHandler ¶ added in v0.22.0
func NewJSONHandler() *JSONHandler
NewJSONHandler creates a handler that collects submit results as JSON data.
func (*JSONHandler) Confirm ¶ added in v0.22.0
func (h *JSONHandler) Confirm(_ string, defaultYes bool) (bool, error)
Confirm auto-confirms with the default value — JSON output is non-interactive.
func (*JSONHandler) IsInteractive ¶ added in v0.22.0
func (h *JSONHandler) IsInteractive() bool
IsInteractive returns false — JSON handlers never prompt.
func (*JSONHandler) OnEvent ¶ added in v0.22.0
func (h *JSONHandler) OnEvent(e Event)
OnEvent implements Handler.
func (*JSONHandler) SetError ¶ added in v0.22.0
func (h *JSONHandler) SetError(err error)
SetError records a run-level error on the result.
type JSONResult ¶ added in v0.22.0
type JSONResult struct {
Outcome CompletionOutcome `json:"outcome"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
Branches []JSONBranchResult `json:"branches"`
}
JSONResult is the machine-readable summary of a submit run.
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
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 PlanningCompleteEvent ¶ added in v0.22.0
type PlanningCompleteEvent struct{}
PlanningCompleteEvent indicates that all BranchPlanEvents have been emitted. Handlers that buffer plan rows can render the complete plan before any confirmation prompt or submission starts.
type PreparingEvent ¶
type PreparingEvent struct{}
PreparingEvent indicates the preparation/validation phase has started.
type RestackEvent ¶
RestackEvent indicates restack phase status.
type StackDisplayEvent ¶
type StackDisplayEvent struct {
Stack StackSnapshot
}
StackDisplayEvent indicates the initial stack visualization phase. Handlers can use this to display the branches that will be processed.
type StackSnapshot ¶ added in v0.22.0
type StackSnapshot struct {
Branches []string // branches in the stack, in order
CurrentBranch string // currently checked out branch
TrunkBranch string // trunk/main branch name
ParentMap map[string]string // branch -> parent
FixedMap map[string]bool // branch -> is fixed (doesn't need restack)
ScopeMap map[string]string // branch -> scope
WorktreeMap map[string]string // branch -> worktree path (for stack roots with managed worktrees)
}
StackSnapshot contains the branch relationships and metadata needed to render the stack being submitted. This is action-layer data; adapters decide how to visualize it.
type SubmissionStartEvent ¶
type SubmissionStartEvent struct {
Branches []BranchInfo
}
SubmissionStartEvent indicates the submission phase is beginning.