Documentation
¶
Overview ¶
Package propose writes the release branch and opens or updates its merge request.
It composes two halves that are independently testable: the git side (tree), which needs no credentials, and the forge side, which is reached through the narrowest interface that does the job rather than through a whole provider.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMissingField = errors.New("release proposal: missing required field")
ErrMissingField reports a required input absent from a Request.
Functions ¶
This section is empty.
Types ¶
type LabelPreparer ¶ added in v0.19.0
type LabelPreparer interface {
Prepare(ctx context.Context, owner, repo string, labels []string) error
}
LabelPreparer makes sure the labels a merge request asks for exist before it is opened (spec 0029 D9). Satisfied by [labels.Preparer].
type Option ¶ added in v0.19.0
type Option func(*Proposer)
Option configures a Proposer.
func WithLabelPreparer ¶ added in v0.19.0
func WithLabelPreparer(labels LabelPreparer) Option
WithLabelPreparer offers to create missing labels before a merge request is opened. Without one, a missing label is only reported.
type Outcome ¶
type Outcome struct {
Action Action
Number int
URL string
Title string
Body string
// Commit is the release commit written; Base is the target head it was cut
// from.
Commit string
Base string
// NotHonoured names what the forge could not apply to the merge request.
// The request EXISTS when this is set — see the note in open().
NotHonoured string
// Unlabelled are the requested labels the forge left off a merge request
// it reported as created, which is what a missing label looks like (spec
// 0029 D8). Empty when the labels were dropped for any other reason.
Unlabelled []string
// Unprepared is why the labels could not be offered for creation. The
// merge request was opened regardless (spec 0029 D9).
Unprepared string
}
Outcome reports what happened.
type Proposer ¶
type Proposer struct {
// contains filtered or unexported fields
}
Proposer writes the release branch and its merge request.
func (*Proposer) Do ¶
Do re-cuts the release branch, then opens or updates its merge request.
The branch is written FIRST, deliberately. A merge request pointing at a branch that was never pushed is visible and wrong; a pushed branch with no merge request is invisible and self-corrects on the next run.
type Recutter ¶
Recutter re-cuts the release branch. Satisfied by tree.Recutter.
type Request ¶
type Request struct {
Owner string
Repo string
// Remote is the clone location for the re-cut.
Remote string
// Target is the branch being released from; Branch is the release branch.
Target string
Branch string
Version string
Changelog string
Considered int
// Tags names every tag the request proposes, root first (spec 0010 D5).
// Empty means the one root tag Version names.
Tags []string
// Files are written into the release commit — the changelog, and whatever
// else a release touches.
Files []tree.File
Author tree.Author
// Labels are asked for when the merge request is opened, and never after:
// go/forge sets labels on create only (spec 0029 D4).
Labels []string
}
Request is one proposal.
type Writer ¶
type Writer interface {
Find(ctx context.Context, owner, repo, sourceBranch string) (forge.PullRequest, error)
Create(ctx context.Context, owner, repo string, draft forge.PullRequestDraft) (forge.PullRequest, error)
Update(ctx context.Context, owner, repo string, number int, title, body string) error
}
Writer is the part of forge.PullRequests that `propose` needs, and nothing more: it cannot close a merge request, and it cannot resolve a merged commit. Declaring the subset keeps the contract honest and lets a three-method fake satisfy it.
Satisfied by forge.PullRequests.