Documentation
¶
Overview ¶
Package gitlab is the GitLab provider: it talks to GitLab through the glab CLI.
Index ¶
- Variables
- func ExecRunner(args ...string) ([]byte, error)
- func Plugin(run Runner) protocol.Plugin
- func StripDraft(title string) string
- func ToCR(m *MR) *protocol.CR
- type BranchInfo
- type Client
- func (c *Client) CancelAutoMerge(iid int) error
- func (c *Client) CreateMR(n NewMR) (*MR, error)
- func (c *Client) FindMRForBranch(branch string) (*MR, error)
- func (c *Client) GetBranch(name string) (*BranchInfo, error)
- func (c *Client) GetMR(iid int) (*MR, error)
- func (c *Client) GetProject() (*ProjectInfo, error)
- func (c *Client) ListMRsTargeting(branch string) ([]*MR, error)
- func (c *Client) MarkReady(mr *MR) (*MR, error)
- func (c *Client) Merge(iid int, squash bool, sha string) (*MR, error)
- func (c *Client) SearchMRs(text string) ([]*MR, error)
- func (c *Client) UpdateMR(iid int, fields map[string]any) (*MR, error)
- type MR
- type NewMR
- type Project
- type ProjectInfo
- type Provider
- func (p *Provider) CancelAutoMerge(n int) error
- func (p *Provider) CreateCR(n protocol.NewCR) (*protocol.CR, error)
- func (p *Provider) FindCRForBranch(branch string) (*protocol.CR, error)
- func (p *Provider) GetBranch(name string) (*protocol.Branch, error)
- func (p *Provider) GetCR(n int) (*protocol.CR, error)
- func (p *Provider) GetRepo() (*protocol.RepoSettings, error)
- func (p *Provider) ListCRsTargeting(branch string) ([]*protocol.CR, error)
- func (p *Provider) MarkReady(n int) (*protocol.CR, error)
- func (p *Provider) Merge(n int, method, sha string) (*protocol.CR, error)
- func (p *Provider) SearchCRs(text string) ([]*protocol.CR, error)
- func (p *Provider) SyncStack([]int) error
- func (p *Provider) Unstack([]int) error
- func (p *Provider) UpdateCR(n int, u protocol.Update) (*protocol.CR, error)
- type Runner
Constants ¶
This section is empty.
Variables ¶
var Info = protocol.Info{ Name: "gitlab", Terms: protocol.Terms{Short: "MR", Long: "merge request", Ref: "!%d"}, MergeMethods: []string{protocol.MethodMerge, protocol.MethodSquash, protocol.MethodRebase}, }
Info describes the GitLab provider.
Functions ¶
func StripDraft ¶
StripDraft removes GitLab draft prefixes from a title.
Types ¶
type BranchInfo ¶
BranchInfo is the subset of a repository branch that git-stack uses.
type Client ¶
Client makes GitLab API calls for one project.
func (*Client) CancelAutoMerge ¶
CancelAutoMerge turns off "merge when pipeline succeeds".
func (*Client) FindMRForBranch ¶
FindMRForBranch returns the open MR for branch, else the most recently merged one, else nil. MRs from forks are ignored: their source branch is someone else's branch that only shares the name.
func (*Client) GetBranch ¶
func (c *Client) GetBranch(name string) (*BranchInfo, error)
GetBranch fetches a branch of the project.
func (*Client) GetProject ¶
func (c *Client) GetProject() (*ProjectInfo, error)
GetProject fetches project settings.
func (*Client) ListMRsTargeting ¶
ListMRsTargeting returns open MRs, not from forks, whose target branch is branch.
func (*Client) Merge ¶
Merge asks GitLab to merge the MR at sha. It is requested as auto-merge, so GitLab merges at once when nothing is pending, waits for the pipeline, or adds the MR to a merge train. The source branch is kept; callers delete it once dependent MRs are retargeted.
type MR ¶
type MR struct {
IID int `json:"iid"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"` // opened, closed, merged, locked
Draft bool `json:"draft"`
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
WebURL string `json:"web_url"`
SHA string `json:"sha"`
AutoMerge bool `json:"merge_when_pipeline_succeeds"`
// RemoveSource is the MR's "delete source branch" option.
RemoveSource bool `json:"force_remove_source_branch"`
// MergeStatus is GitLab's detailed_merge_status (mergeable, checking, ...).
MergeStatus string `json:"detailed_merge_status"`
MergeError string `json:"merge_error"`
// Squash is the MR's own "squash commits" setting, which GitLab applies
// when merging unless the project forces squashing on or off.
Squash bool `json:"squash"`
// SourceProjectID differs from TargetProjectID for an MR from a fork.
SourceProjectID int `json:"source_project_id"`
TargetProjectID int `json:"target_project_id"`
}
MR is the subset of a GitLab merge request that git-stack uses.
type ProjectInfo ¶
type ProjectInfo struct {
SquashOption string `json:"squash_option"` // never, always, default_on, default_off
}
ProjectInfo is the subset of project settings git-stack uses.
type Provider ¶
type Provider struct {
C *Client
}
Provider adapts Client to protocol.Provider.
func (*Provider) CancelAutoMerge ¶
func (*Provider) FindCRForBranch ¶
func (*Provider) ListCRsTargeting ¶
func (*Provider) Merge ¶
Merge requests an auto-merge. GitLab has no per-merge choice between a merge commit and a rebase (that is the project's merge method), so "merge" and "rebase" both keep the commits.
func (*Provider) SyncStack ¶
SyncStack is a no-op: GitLab has no stack object; the description block is the stack.