Documentation
¶
Overview ¶
Package submit implements change submission handling. This is used by the various 'submit' commands in the CLI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchOptions ¶ added in v0.17.0
type BatchOptions struct {
UpdateOnlyDefault bool `config:"submit.updateOnly" hidden:"" default:"false"`
}
BatchOptions defines options that are only available to batch submit operations.
type BatchRequest ¶
type BatchRequest struct { Branches []string // required Options *Options BatchOptions *BatchOptions // required }
BatchRequest is a request to submit one or more change requests.
type GitRepository ¶
type GitRepository interface { PeelToCommit(ctx context.Context, ref string) (git.Hash, error) BranchUpstream(ctx context.Context, branch string) (string, error) SetBranchUpstream(ctx context.Context, branch string, upstream string) error Var(ctx context.Context, name string) (string, error) CommitMessageRange(ctx context.Context, start string, stop string) ([]git.CommitMessage, error) }
GitRepository is a subset of the git.Repository interface that is used by the submit handler.
type GitWorktree ¶
type GitWorktree interface {
Push(ctx context.Context, opts git.PushOptions) error
}
GitWorktree is a subset of the git.Worktree interface that is used by the submit handler.
type Handler ¶
type Handler struct { Log *silog.Logger // required View ui.View // required Repository GitRepository // required Worktree GitWorktree // required Store Store // required Service Service // required Browser browser.Launcher // required // TODO: these should not be a func reference // this whole memoize thing is a bit of a hack FindRemote func(ctx context.Context) (string, error) // required OpenRemoteRepository func(ctx context.Context, remote string) (forge.Repository, error) // required // contains filtered or unexported fields }
Handler implements support for submission of change requests.
func (*Handler) Remote ¶
Remote returns the remote name for the current repository, memoizing the result.
func (*Handler) RemoteRepository ¶
RemoteRepository returns the remote repository for the current repository, memoizing the result.
func (*Handler) Submit ¶
Submit submits a single branch to a remote repository, creating or updating a change request as needed.
func (*Handler) SubmitBatch ¶
func (h *Handler) SubmitBatch(ctx context.Context, req *BatchRequest) error
SubmitBatch submits a batch of branches to a remote repository, creating or updating change requests as needed.
type NavCommentSync ¶
type NavCommentSync int
NavCommentSync specifies the scope of navigation comment updates.
const ( // only for branches that are being submitted. // // This is the default. NavCommentSyncBranch NavCommentSync = iota // for all submitted branches and their downstack branches. NavCommentSyncDownstack )
func (NavCommentSync) String ¶
func (s NavCommentSync) String() string
String returns the string representation of the NavCommentSync.
func (*NavCommentSync) UnmarshalText ¶
func (s *NavCommentSync) UnmarshalText(bs []byte) error
UnmarshalText decodes a NavCommentSync from text. It supports "branch" and "downstack" values.
type NavCommentWhen ¶
type NavCommentWhen int
NavCommentWhen specifies when a navigation comment should be posted (or updated if it already exists).
const ( // This is the default. NavCommentAlways NavCommentWhen = iota // If an existing comment is found, it is left as is. NavCommentNever // only if there are multiple branches in the stack // that the current branch is part of. NavCommentOnMultiple )
func (NavCommentWhen) String ¶
func (f NavCommentWhen) String() string
func (*NavCommentWhen) UnmarshalText ¶
func (f *NavCommentWhen) UnmarshalText(bs []byte) error
UnmarshalText decodes a NavCommentWhen from text. It supports "true", "false", and "multiple" values.
type OpenWeb ¶
type OpenWeb int
OpenWeb defines options for the --web flag.
const ( // OpenWebNever indicates that CRs should not be opened in a browser. OpenWebNever OpenWeb = iota // OpenWebAlways indicates that CRs should always be opened in a browser. OpenWebAlways // OpenWebOnCreate indicates that CRs should be opened in a browser // only when they are first created. OpenWebOnCreate )
type Options ¶
type Options struct { DryRun bool `short:"n" help:"Don't actually submit the stack"` Fill bool `short:"c" help:"Fill in the change title and body from the commit messages"` // TODO: Default to Fill if --no-prompt? Draft *bool `negatable:"" help:"Whether to mark change requests as drafts"` Publish bool `` /* 134-byte string literal not displayed */ Web OpenWeb `` /* 135-byte string literal not displayed */ Force bool `help:"Force push, bypassing safety checks"` NoVerify bool `help:"Bypass pre-push hooks when pushing to the remote." released:"v0.15.0"` UpdateOnly *bool `short:"u" negatable:"" help:"Only update existing change requests, do not create new ones"` // DraftDefault is used to set the default draft value // when creating new Change Requests. // // --draft/--no-draft will override this value. DraftDefault bool `config:"submit.draft" hidden:"" default:"false"` Labels []string `name:"label" short:"l" help:"Add labels to the change request. Pass multiple times or separate with commas."` ConfiguredLabels []string `name:"configured-labels" hidden:"" config:"submit.label"` // merged with Labels // ListTemplatesTimeout controls the timeout for listing CR templates. ListTemplatesTimeout time.Duration `hidden:"" config:"submit.listTemplatesTimeout" help:"Timeout for listing CR templates" default:"1s"` // Template specifies the template to use when multiple templates are available. // If set, this template will be automatically selected instead of prompting the user. // The value should match the filename of one of the available templates. Template string `hidden:"" config:"submit.template" help:"Default template to use when multiple templates are available"` }
Options defines options for the submit operations.
Options translate into user-facing command line flags or configuration options, so care must be taken when adding things here.
type Request ¶
type Request struct { // Branch is the name of the branch to submit. Branch string // required // Title and Body are the title and body of the change request. Title, Body string // optional // Options are the options for the submit operation. Options *Options // optional }
Request is a request to submit a single branch to a remote repository.
type Service ¶
type Service interface { LoadBranches(context.Context) ([]spice.LoadBranchItem, error) VerifyRestacked(ctx context.Context, name string) error LookupBranch(ctx context.Context, name string) (*spice.LookupBranchResponse, error) UnusedBranchName(ctx context.Context, remote string, branch string) (string, error) ListChangeTemplates(context.Context, string, forge.Repository) ([]*forge.ChangeTemplate, error) }
Service provides access to the Spice service.
type Store ¶
type Store interface { BeginBranchTx() *state.BranchTx Trunk() string LoadPreparedBranch(ctx context.Context, name string) (*state.PreparedBranch, error) SavePreparedBranch(ctx context.Context, b *state.PreparedBranch) error ClearPreparedBranch(ctx context.Context, name string) error }
Store provides read/write access to the state store.