gitlab

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package gitlab provides access to GitLab via the official client-go SDK.

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 talks to the GitLab API on behalf of the authenticated user.

func New

func New(cfg operations.GitLabConfig) (*Client, error)

New builds a GitLab client from the given credentials. When cfg.URL is set (self-hosted instance), it is used as the API base URL; /api/v4 is appended automatically when missing.

func (*Client) CloseIssue

func (c *Client) CloseIssue(ctx context.Context, repo string, number int) error

CloseIssue closes an issue.

func (*Client) ClosePR

func (c *Client) ClosePR(ctx context.Context, repo string, number int) error

ClosePR closes a merge request without merging it.

func (*Client) CommentIssue

func (c *Client) CommentIssue(ctx context.Context, repo string, number int, body string) error

CommentIssue adds a note to an issue.

func (*Client) CommentPR

func (c *Client) CommentPR(ctx context.Context, repo string, number int, body string) error

CommentPR adds a note to a merge request.

func (*Client) CreateIssue

CreateIssue opens a new issue.

func (*Client) CreatePR

func (c *Client) CreatePR(ctx context.Context, in operations.PRInput) (operations.PRDetail, error)

CreatePR opens a merge request.

func (*Client) CreateRepo

func (c *Client) CreateRepo(ctx context.Context, in operations.RepoInput) (operations.Repo, error)

CreateRepo creates a project. GitLab projects live in the authenticated user's namespace unless in.Owner names a group, in which case the group's projects API is used.

func (*Client) DeleteRepo

func (c *Client) DeleteRepo(ctx context.Context, fullName string) error

DeleteRepo deletes a project. fullName is namespace/path.

func (*Client) FetchSpec

func (c *Client) FetchSpec(ctx context.Context, repo string, number int) (operations.FetchSpec, error)

FetchSpec returns how to fetch a merge request head locally.

GitLab publishes every merge request head under refs/merge-requests/N/head, which also exists for fork merge requests.

func (*Client) GetIssue

func (c *Client) GetIssue(ctx context.Context, repo string, number int) (operations.IssueDetail, error)

GetIssue returns a single issue in full.

func (*Client) GetPR

func (c *Client) GetPR(ctx context.Context, repo string, number int) (operations.PRDetail, error)

GetPR returns a single merge request in full.

func (*Client) ListIssues

func (c *Client) ListIssues(ctx context.Context) ([]operations.Issue, error)

ListIssues returns open issues assigned to the authenticated user.

func (*Client) ListPRs

func (c *Client) ListPRs(ctx context.Context) ([]operations.PR, error)

ListPRs returns open merge requests across all projects.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context) ([]operations.Project, error)

ListProjects lists projects, which on GitLab are the repositories.

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context) ([]operations.Repo, error)

ListRepos returns the projects owned by the authenticated user.

func (*Client) ListRuns

func (c *Client) ListRuns(ctx context.Context, fullName string) ([]operations.Run, error)

ListRuns lists pipelines for a project. fullName is namespace/path.

func (*Client) ListWorkflows

func (c *Client) ListWorkflows(ctx context.Context, fullName string) ([]operations.Workflow, error)

ListWorkflows returns ErrNotSupported: GitLab has no workflow-definition concept; its pipelines are surfaced by ListRuns.

func (*Client) MergePR

func (c *Client) MergePR(ctx context.Context, repo string, number int, opts operations.MergeOptions) error

MergePR merges a merge request.

GitLab does not accept a merge strategy per request: the merge method is a project setting (merge commit, fast-forward or rebase). Only squash can be requested per merge, so that is the only method acted on here; the others fall back to whatever the project is configured to do.

func (*Client) Name

func (c *Client) Name() string

Name returns the instance name.

func (*Client) PRDiff

func (c *Client) PRDiff(ctx context.Context, repo string, number int) (string, error)

PRDiff returns the unified diff of a merge request.

func (*Client) RenameRepo

func (c *Client) RenameRepo(ctx context.Context, fullName, newName string) (operations.Repo, error)

RenameRepo renames a project. fullName is namespace/path.

func (*Client) SetForgeLabel

func (c *Client) SetForgeLabel(label string)

SetForgeLabel overrides the forge label the client stamps on returned resources. Used to give user-named aliases the right identity in listings while the GitLab client does the API work.

func (*Client) SetInstance

func (c *Client) SetInstance(name string)

SetInstance names this client's instance (default: the forge type).

func (*Client) SetPRReady

func (c *Client) SetPRReady(ctx context.Context, repo string, number int, ready bool) error

SetPRReady toggles a merge request between draft and ready.

GitLab models the draft state as a "Draft:" prefix on the title rather than as a settable flag, so the title is rewritten. This is the same approach glab takes, and it keeps working on self-hosted versions that predate the draft field on the API.

func (*Client) SetVisibility

func (c *Client) SetVisibility(ctx context.Context, fullName string, private bool) (operations.Repo, error)

SetVisibility changes a project's visibility. fullName is namespace/path.

Jump to

Keyboard shortcuts

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