Documentation
¶
Overview ¶
Package engine implements multi-branch operations over a stack.
Index ¶
- func Block(c *forge.Forge, urls map[int]string) forge.Block
- func DefaultTitleBody(g *git.Repo, parent, branch string) (string, string)
- func MarkMergedByAncestry(g *git.Repo, s *stack.Stack, trunkSHA string) []string
- func Push(g *git.Repo, remote string, branches []string) error
- func RemoteStack(s *stack.Stack, known map[string]*forge.CR) *forge.StackInfo
- func SetBody(c *forge.Forge, blk forge.Block, info forge.StackInfo, body string, self int) (string, error)
- func StackInfo(s *stack.Stack) forge.StackInfo
- func SyncMRs(c *forge.Forge, g *git.Repo, s *stack.Stack) (map[string]*forge.CR, error)
- func UpdateBlocks(c *forge.Forge, s *stack.Stack, known map[string]*forge.CR) error
- type Layer
- type Modifier
- type RebaseOptions
- type Rebaser
- func (r *Rebaser) Abort() error
- func (r *Rebaser) Continue(f *stack.File) error
- func (r *Rebaser) FastForwardFromRemote(s *stack.Stack, remote string) (string, error)
- func (r *Rebaser) InProgress() bool
- func (r *Rebaser) Preflight(order []string) error
- func (r *Rebaser) Start(s *stack.Stack, o RebaseOptions) error
- func (r *Rebaser) UpdateFromRemote(s *stack.Stack, remote string) (string, error)
- type Relation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Block ¶
Block returns c's block renderer; urls gives CR web URLs, for hosts without a short reference syntax.
func DefaultTitleBody ¶
DefaultTitleBody derives an PR title and description from a layer's commits: a single commit gives its subject and body, otherwise the humanized branch name.
func MarkMergedByAncestry ¶
MarkMergedByAncestry marks layers merged when there is no host to ask: a layer with commits of its own whose tip is contained in trunkSHA. Squash merges rewrite the commits and cannot be told apart from unmerged work. Layers are marked from the bottom up and the walk stops at the first one that is not merged. It returns the names of the layers it marked.
func Push ¶
Push pushes branches to remote in one `git push`. Each branch carries an explicit --force-with-lease on the remote-tracking value, and is only pushed if that value was integrated locally (git.Repo.Includes): a commit someone else pushed, such as an applied review suggestion, is refused rather than overwritten, even right after a fetch has refreshed the tracking refs. Remote commits whose changes the branch already has (git.Repo.HasPatches), such as GitHub restacking a native stack after a merge, are overwritten.
func RemoteStack ¶
RemoteStack returns the stack block from the first open PR of s.
func SetBody ¶
func SetBody(c *forge.Forge, blk forge.Block, info forge.StackInfo, body string, self int) (string, error)
SetBody returns body with the stack block for CR self, checking the host's description size limit.
func SyncMRs ¶
SyncMRs refreshes each unmerged layer's PR from the host and marks merged layers. It returns the PRs found, keyed by branch. Merged layers are not fetched again: merged is final on the host.
An PR found by branch name alone (no PR recorded, or the recorded one was closed) is only taken if it is open, or if it merged exactly what the local branch holds: an old merged PR whose source branch merely had the same name must not make a new layer count as merged.
Types ¶
type Layer ¶
type Layer struct {
Name string `json:"name"`
Orig string `json:"orig,omitempty"`
Sources []string `json:"sources,omitempty"`
}
Layer is one layer of the stack after a modify: Name holds the commits of the original layers listed in Sources, in order. Orig is the layer's original name ("" for an inserted layer).
type Modifier ¶
type Modifier struct {
Repo *git.Repo
Store stack.Store
Log func(format string, args ...any)
// Ref formats a CR number for messages, e.g. "!12"; nil writes "#12".
Ref func(n int) string
// CR names a change request in messages, e.g. "MR"; "" is "PR".
CR string
}
Modifier applies a restructured layer list to a stack.
func (*Modifier) Abort ¶
Abort cancels a paused modify. Branches were not moved yet, so only the cherry-pick and the checkout need undoing.
func (*Modifier) Apply ¶
Apply rebuilds the stack as layers (bottom first). On success it updates s and returns nil; on a conflict it pauses with a journal (exit 3).
func (*Modifier) CheckLinear ¶
CheckLinear fails if any layer contains merge commits.
type RebaseOptions ¶
type RebaseOptions struct {
Anchor string // branch that --downstack/--upstack are relative to
Downstack bool // trunk up to and including Anchor
Upstack bool // Anchor up to the top
NoTrunk bool // skip the fetch and leave the bottom layer where it is
Remote string // defaults to the stack's remote
PreserveDates bool // --committer-date-is-author-date
// AbortOnConflict restores every branch instead of pausing on a conflict.
AbortOnConflict bool
// TrunkSHA, when set, is the commit to rebase the bottom layer onto: the
// caller has already fetched and fast-forwarded (FastForwardFromRemote).
TrunkSHA string
}
RebaseOptions selects which layers to rebase and how.
type Rebaser ¶
Rebaser runs cascade rebases. Repo is the worktree the command was run from.
func (*Rebaser) FastForwardFromRemote ¶
FastForwardFromRemote is UpdateFromRemote for a caller that has just fetched.
func (*Rebaser) InProgress ¶
InProgress reports whether a cascade rebase is paused.
func (*Rebaser) Preflight ¶
Preflight checks that the worktrees a rebase of order would touch are clean and idle.
type Relation ¶
type Relation int
Relation describes how the stack on the host compares to the local stack.