gitlab

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package gitlab implements forge.Forge against the GitLab REST API. It is reached only through the forge.Forge interface; no view imports it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client adapts the GitLab SDK to forge.Forge.

func New

func New(profile, host, token string, transport http.RoundTripper) (*Client, error)

New builds a Client for one profile/host pair using a token obtained from the glab CLI.

transport, when given, is the caching round-tripper. It is installed here rather than wrapped around forge.Forge so that every endpoint is covered without any call site knowing about it.

func (*Client) Capabilities

func (c *Client) Capabilities() forge.Caps

Capabilities reports what GitLab accepts.

Multi-line suggestions have been on by default since 13.7; a project that turned them off rejects the comment, which surfaces as an API error rather than a silent miss.

func (*Client) Comment

func (c *Client) Comment(ctx context.Context, ref forge.Ref, target, body string) error

Comment posts a note on an issue or merge request.

func (*Client) CreateDiffThread

func (c *Client) CreateDiffThread(ctx context.Context, ref forge.Ref, mr int, dc forge.DiffComment) error

CreateDiffThread opens a discussion anchored to a place in the diff.

GitLab positions a comment with the three commits the diff was taken against plus the file and line. Without them the API takes the comment but drops it at the bottom of the discussion, which is a different comment from the one the reviewer wrote — so a missing position is refused here rather than posted somewhere else.

func (*Client) CreateThread

func (c *Client) CreateThread(ctx context.Context, ref forge.Ref, target, body string) error

CreateThread starts a new discussion on an issue or merge request.

It is a discussion rather than a note so a review comment opens its own resolvable thread, which is what a reviewer expects to be able to close.

func (*Client) FileContent

func (c *Client) FileContent(ctx context.Context, ref forge.Ref, path, rev string) ([]byte, error)

FileContent returns a file's bytes at a revision.

func (*Client) GroupIssues

func (c *Client) GroupIssues(ctx context.Context, group string, f forge.IssueFilter) ([]forge.Issue, error)

GroupIssues lists issues across every project in a group — what GitLab's group issue board shows.

func (*Client) Issue

func (c *Client) Issue(ctx context.Context, ref forge.Ref, id int) (forge.Issue, error)

Issue fetches one issue by its number.

func (*Client) Issues

func (c *Client) Issues(ctx context.Context, ref forge.Ref, f forge.IssueFilter) ([]forge.Issue, error)

Issues lists issues in a project.

The status query is scoped to the project rather than to the issues, so when one is wanted it is started alongside the listing instead of after it: the board pays for the slower of the two rather than for both.

func (*Client) JobLog

func (c *Client) JobLog(ctx context.Context, ref forge.Ref, jobID int) (io.ReadCloser, error)

JobLog returns a job's trace. GitLab hands back the whole trace as a buffer, so the reader needs no closing beyond satisfying the interface.

func (*Client) Jobs

func (c *Client) Jobs(ctx context.Context, ref forge.Ref, pipelineID int) ([]forge.Job, error)

Jobs lists the steps of one pipeline, in the order GitLab reports them.

func (*Client) Merge

func (c *Client) Merge(ctx context.Context, ref forge.Ref, mr int) error

Merge merges a merge request immediately.

It deliberately does not set auto-merge: a stack merges under the user's explicit, confirmed keypress, and a queued merge that lands later would take the decision out of their hands.

func (*Client) MergeRequest

func (c *Client) MergeRequest(ctx context.Context, ref forge.Ref, mr int) (forge.MergeRequest, error)

MergeRequest fetches one merge request by its number.

func (*Client) MergeRequestDiff

func (c *Client) MergeRequestDiff(ctx context.Context, ref forge.Ref, mr int) (string, error)

MergeRequestDiff returns the merge request as a unified diff.

GitLab hands back one entry per file, carrying only the hunks — no "diff --git" or ---/+++ headers. Those are reconstructed here so the result is a real unified diff that any diff tool can read.

func (*Client) MergeRequests

func (c *Client) MergeRequests(ctx context.Context, ref forge.Ref, f forge.MRFilter) ([]forge.MergeRequest, error)

MergeRequests lists merge requests in a project.

func (*Client) MyWork

func (c *Client) MyWork(ctx context.Context, f forge.MyWorkFilter) ([]forge.WorkItem, error)

MyWork lists the current user's issues and merge requests across every project they can see.

GitLab has no single "everything of mine" endpoint, so this runs one query per kind and role — up to five — and merges them.

They run at once, and are merged in the order they were *asked for* rather than the order they arrived. An item matching several roles keeps the first in priority order, and that has to be a property of the list rather than of which request happened to come back quickest.

func (*Client) Namespaces

func (c *Client) Namespaces(ctx context.Context, parent string) ([]forge.Namespace, error)

Namespaces lists subgroups of parent, or top-level groups when parent is "".

func (*Client) Pipelines

func (c *Client) Pipelines(ctx context.Context, ref forge.Ref, f forge.PipelineFilter) ([]forge.Pipeline, error)

Pipelines lists a project's CI runs, most recent first.

func (*Client) Rebase

func (c *Client) Rebase(ctx context.Context, ref forge.Ref, mr int) error

Rebase brings a merge request up to date with its target branch through GitLab's API. gu never runs git locally, so this is the only rebase path.

func (*Client) Repos

func (c *Client) Repos(ctx context.Context, namespace string) ([]forge.Repo, error)

Repos lists the projects directly inside a group.

Simple is on because toRepo reads six fields and the full representation is closer to sixty, most of them settings blocks and permission matrices no listing has ever drawn. On a group of eleven projects that is 65 KB against 9.5 KB, and a second against under half of one — paid on the explorer's most common screen, every time it opens.

func (*Client) RetryPipeline

func (c *Client) RetryPipeline(ctx context.Context, ref forge.Ref, pipelineID int) error

RetryPipeline re-runs a pipeline's failed and canceled jobs.

func (*Client) SetFields

func (c *Client) SetFields(ctx context.Context, ref forge.Ref, target string, patch forge.FieldPatch) error

SetFields applies a partial update to an issue or merge request.

func (*Client) Starred

func (c *Client) Starred(ctx context.Context) ([]forge.Repo, error)

Starred lists the current user's starred projects.

func (*Client) Threads

func (c *Client) Threads(ctx context.Context, ref forge.Ref, target string) ([]forge.Thread, error)

Threads lists the discussions on an issue or merge request.

It uses the discussions endpoint rather than notes: notes arrive as a flat list, and the reply structure of a review conversation is the whole point of showing them.

Every page is followed. A long-running merge request goes past a hundred discussions easily, and stopping at the first page did not lose the last comments visibly — it lost them silently, which is worse: the page looked complete and was short by a quarter.

func (*Client) Tree

func (c *Client) Tree(ctx context.Context, ref forge.Ref, path, rev string) ([]forge.TreeEntry, error)

Tree lists the entries directly under a path.

func (*Client) Whoami

func (c *Client) Whoami(ctx context.Context) (forge.User, error)

Whoami identifies the authenticated user.

Jump to

Keyboard shortcuts

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