{"modulePath":"github.com/DomBlack/git-stack","version":"v0.5.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package forge\n\nPackage forge is the port for pull-request operations. It is vendor neutral: GitHub via gh, GitHub via the REST API and GitLab are adapters.\n\n## Types\n\n```go\ntype CheckSummary struct {\n\t// Failing checks finished without passing (failed, errored, timed\n\t// out, cancelled, needing action).\n\tFailing []string `json:\"failing,omitempty\"`\n\t// Pending checks are queued, waiting or still running.\n\tPending []string `json:\"pending,omitempty\"`\n}\n```\nCheckSummary is where the checks on a pull request's head commit stand, by name. Checks that passed, or were skipped or neutral, aren't listed.\n\n```go\nfunc (c CheckSummary) Clean() bool\n```\nClean reports whether nothing is failing or still running.\n\n```go\ntype CreatePR struct {\n\tHead, Base  string\n\tTitle, Body string\n\tDraft       bool\n}\n```\nCreatePR describes a new pull request.\n\n```go\ntype Forge interface {\n\t// ListPRs returns every pull request whose head is a branch of this\n\t// repository, in one call.\n\tListPRs(ctx context.Context, repo git.Repo) ([]PullRequest, error)\n\t// PR looks up one pull request by number, forks included. One that\n\t// doesn't exist is a *stack.Error of kind invalid_args.\n\tPR(ctx context.Context, repo git.Repo, number int) (PullRequest, error)\n\t// OpenPRFor finds the open (or draft) pull request whose head is\n\t// branch in this repository, however old it is; false when there is\n\t// none. Pull requests from forks with a branch of the same name don't\n\t// count.\n\tOpenPRFor(ctx context.Context, repo git.Repo, branch string) (PullRequest, bool, error)\n\tCreatePR(ctx context.Context, repo git.Repo, in CreatePR) (PullRequest, error)\n\tUpdatePR(ctx context.Context, repo git.Repo, number int, in UpdatePR) error\n\t// MergeStack merges pull request number together with every open pull\n\t// request below it in its stack, all or nothing, and waits until the\n\t// forge reports the result (or has queued it). A refusal, such as a\n\t// draft in the way or a failed check, comes back as a *stack.Error.\n\tMergeStack(ctx context.Context, repo git.Repo, number int, method MergeMethod) (MergeOutcome, error)\n\t// Checks reports the checks on the current head commit of each pull\n\t// request in numbers, asking the forge about all of them together\n\t// rather than one at a time. A pull request with no checks at all may\n\t// be missing from the map.\n\tChecks(ctx context.Context, repo git.Repo, numbers []int) (map[int]CheckSummary, error)\n\t// CreateStack groups pull requests into a stack on the forge, bottom\n\t// to top. GitHub needs at least two, none of them already in a stack,\n\t// each based on the head of the one before. A refusal comes back as a\n\t// *stack.Error of kind api_failure carrying the forge's message.\n\tCreateStack(ctx context.Context, repo git.Repo, numbers []int) (StackRef, error)\n\t// ClosePR closes pull request number without merging it, leaving\n\t// comment on it first. One that is already closed or merged is not an\n\t// error.\n\tClosePR(ctx context.Context, repo git.Repo, number int, comment string) error\n\t// RenameBranch renames branch from to to on the forge, which keeps its\n\t// pull request attached and retargets the pull requests based on it. A\n\t// refusal (the name is taken, no permission) comes back as a\n\t// *stack.Error of kind api_failure carrying the forge's message.\n\tRenameBranch(ctx context.Context, repo git.Repo, from, to string) error\n\t// PullRequestURL is the web address of pull request number, worked out\n\t// from local configuration only (never the network), so output can\n\t// link a PR the forge hasn't been asked about. \"\" when it can't tell.\n\tPullRequestURL(ctx context.Context, repo git.Repo, number int) (string, error)\n}\n```\nForge performs pull-request operations for the repository's remote.\n\n```go\ntype MergeMethod string\n```\nMergeMethod says how a pull request lands on its base.\n\n```go\nconst (\n\t// MergeDefault leaves the choice to the repository's settings.\n\tMergeDefault MergeMethod = \"\"\n\tMergeMerge   MergeMethod = \"merge\"\n\tMergeSquash  MergeMethod = \"squash\"\n\tMergeRebase  MergeMethod = \"rebase\"\n)\n```\n\n```go\ntype MergeOutcome struct {\n\tStatus MergeStatus\n\t// SHA is the merge commit on the base branch; empty when enqueued.\n\tSHA string\n\t// Message is the forge's own description of the outcome, if any.\n\tMessage string\n}\n```\nMergeOutcome reports a finished stack merge.\n\n```go\ntype MergeStatus string\n```\nMergeStatus is where a stack merge ended up.\n\n```go\nconst (\n\t// MergeMerged: the pull requests are on the base branch.\n\tMergeMerged MergeStatus = \"merged\"\n\t// MergeEnqueued: the base branch uses a merge queue and the pull\n\t// requests are in it; they land when the queue gets to them.\n\tMergeEnqueued MergeStatus = \"enqueued\"\n)\n```\n\n```go\ntype PullRequest struct {\n\tNumber int    `json:\"number\"`\n\tURL    string `json:\"url\"`\n\tTitle  string `json:\"title\"`\n\tBody   string `json:\"body,omitempty\"`\n\tState  State  `json:\"state\"`\n\tHead   string `json:\"head\"`\n\tBase   string `json:\"base\"`\n\t// HeadSHA is the head commit the forge last saw for this PR.\n\tHeadSHA string `json:\"headSha,omitempty\"`\n\t// MergeCommit is the commit the PR was merged as, \"\" unless merged.\n\tMergeCommit string    `json:\"mergeCommit,omitempty\"`\n\tUpdatedAt   time.Time `json:\"updatedAt\"`\n\t// Fork is set when the head branch lives in another repository.\n\tFork bool `json:\"fork,omitempty\"`\n}\n```\nPullRequest is a forge-neutral pull request.\n\n```go\ntype StackRef struct {\n\t// ID is the forge's identifier for the stack.\n\tID string\n\t// Number is the stack's number within the repository.\n\tNumber int\n}\n```\nStackRef names a stack of pull requests on the forge.\n\n```go\ntype State string\n```\nState of a pull request.\n\n```go\nconst (\n\tStateOpen   State = \"open\"\n\tStateDraft  State = \"draft\"\n\tStateMerged State = \"merged\"\n\tStateClosed State = \"closed\"\n\t// StateUnknown is used when only a number is known (e.g. from a backend\n\t// snapshot) and the forge has not been consulted.\n\tStateUnknown State = \"\"\n)\n```\n\n```go\ntype UpdatePR struct {\n\tTitle *string\n\tBody  *string\n\tBase  *string\n\t// Ready marks a draft ready for review when true.\n\tReady *bool\n}\n```\nUpdatePR carries optional changes; nil fields are left untouched.\n\n","path":"github.com/DomBlack/git-stack/pkg/forge","name":"forge","synopsis":"Package forge is the port for pull-request operations.","isRedistributable":true}
