propose

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 7 Imported by: 0

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

View Source
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 Action

type Action int

Action reports what `propose` did to the merge request.

const (
	// Unchanged means an open merge request already said exactly this.
	Unchanged Action = iota

	// Created means one was opened.
	Created

	// Updated means an open one was rewritten.
	Updated
)

func (Action) String

func (a Action) String() string

String renders the action for a CLI trace.

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
}

Outcome reports what happened.

type Proposer

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

Proposer writes the release branch and its merge request.

func New

func New(recutter Recutter, writer Writer) *Proposer

New returns a Proposer.

func (*Proposer) Do

func (p *Proposer) Do(ctx context.Context, req Request) (Outcome, error)

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

type Recutter interface {
	Do(ctx context.Context, spec tree.Recut) (tree.Result, error)
}

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
}

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.

Jump to

Keyboard shortcuts

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