gitlab

package
v0.10.266 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package gitlab adapts the GitLab REST API to gitprovider read and write models.

Index

Constants

This section is empty.

Variables

View Source
var ErrValidation = errors.New("gitlab: validation error")

ErrValidation identifies non-retryable adapter input or GitLab validation failures.

Functions

This section is empty.

Types

type Client

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

Client is a GitLab merge-request adapter implementing gitprovider.GitProvider.

func New

func New(opts Options) (*Client, error)

New builds a GitLab client from explicit options.

func NewFromGitConfig

func NewFromGitConfig(git config.GitConfig, store credentials.Reader, opts Options) (*Client, gitprovider.Credential, error)

NewFromGitConfig builds a GitLab client and credential from config plus a token store.

func (*Client) Capabilities

func (c *Client) Capabilities() gitprovider.ProviderCaps

Capabilities returns GitLab feature support.

func (*Client) GetDiff

GetDiff returns the raw unified diff for a merge request. Newer GitLab versions serve it directly; older ones fall back to reconstruction from the per-file diffs listing.

func (*Client) GetDiffBetweenRefs

func (c *Client) GetDiffBetweenRefs(ctx context.Context, ref gitprovider.PRRef, baseSHA, headSHA string) (gitprovider.UnifiedDiff, error)

GetDiffBetweenRefs returns the raw unified diff between two git refs in the merge request's target repository.

func (*Client) GetFileAtRef

func (c *Client) GetFileAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, filePath string) ([]byte, error)

GetFileAtRef returns raw file contents at a git ref.

func (*Client) GetPR

func (c *Client) GetPR(ctx context.Context, ref gitprovider.PRRef) (gitprovider.PR, error)

GetPR returns one merge request snapshot.

func (*Client) Host

func (c *Client) Host() string

Host returns the normalized host this client is bound to.

func (*Client) ListInlineThreads

func (c *Client) ListInlineThreads(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.InlineThread, error)

ListInlineThreads returns merge-request discussions anchored to the diff.

func (*Client) ListIssueComments

func (c *Client) ListIssueComments(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.IssueComment, error)

ListIssueComments returns non-system merge-request notes without a diff position, GitLab's equivalent of pull-request issue comments.

func (*Client) ListReviews

func (c *Client) ListReviews(ctx context.Context, ref gitprovider.PRRef) ([]gitprovider.Review, error)

ListReviews maps current merge-request approvals to provider-neutral reviews. GitLab has no first-class review object: approvals are current state (revoking removes them), and review summaries are posted as notes.

func (*Client) ListTreeAtRef

func (c *Client) ListTreeAtRef(ctx context.Context, ref gitprovider.PRRef, gitRef string, treePath string) ([]gitprovider.TreeEntry, error)

ListTreeAtRef returns the git tree entries at a ref and path.

func (*Client) PostInlineComment

func (c *Client) PostInlineComment(ctx context.Context, ref gitprovider.PRRef, comment gitprovider.InlineComment) (gitprovider.CommentID, error)

PostInlineComment starts a new diff discussion on the merge request.

func (*Client) PostIssueComment

func (c *Client) PostIssueComment(ctx context.Context, ref gitprovider.PRRef, body string) (gitprovider.CommentID, error)

PostIssueComment posts a merge-request note.

func (*Client) ReplyToThread

func (c *Client) ReplyToThread(ctx context.Context, ref gitprovider.PRRef, threadID gitprovider.ThreadID, body string) (gitprovider.CommentID, error)

ReplyToThread adds a note to an existing merge-request discussion.

func (*Client) ResolveThread

func (c *Client) ResolveThread(ctx context.Context, ref gitprovider.PRRef, threadID gitprovider.ThreadID) error

ResolveThread marks a merge-request discussion resolved.

func (*Client) ReviewAuthority

func (c *Client) ReviewAuthority(ctx context.Context, ref gitprovider.PRRef, identity gitprovider.Identity) (gitprovider.ReviewAuthority, error)

ReviewAuthority reports whether the resolved posting identity can approve merge requests on the target project. GitLab requires at least Developer access to approve.

func (*Client) SubmitReview

func (c *Client) SubmitReview(ctx context.Context, ref gitprovider.PRRef, request gitprovider.ReviewRequest) (gitprovider.ReviewID, error)

SubmitReview posts the final review verdict. GitLab has no single review submission primitive, so the approval state changes first (approve for approve events, revoke for request-changes events) and the summary body is then posted as a merge-request note. Ordering matters for retries: the summary note carries the idempotency marker, so it must be the last write.

func (*Client) WhoAmI

WhoAmI returns the identity for the supplied credential.

type Options

type Options struct {
	Host       string
	Token      string
	HTTPClient *http.Client
	BaseURL    string
}

Options configures a GitLab client.

Jump to

Keyboard shortcuts

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