gitlab

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gitlab implements scm.Host backed by the glab CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProjectPath

func ProjectPath(raw string) string

ProjectPath extracts the "group/project" path (no host, no trailing .git) from a GitLab remote URL. GitLab projects can live under nested subgroups, so the full path - not just the last two segments - is returned. It handles HTTPS/ssh:// URLs and scp-style SSH (git@host:group/project.git). Returns "" when no path can be determined; callers treat that as "unknown" and fall back to branch-dependent porcelain.

Types

type CmdFactory

type CmdFactory func(ctx context.Context, name string, args ...string) *exec.Cmd

CmdFactory builds an exec.Cmd in the caller's workdir with the caller's env.

type Host

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

Host talks to GitLab through the glab CLI.

func New

func New(cmd CmdFactory, cliAvailable func() bool, host, projectPath string) *Host

New builds a Host. cliAvailable reports whether the glab binary is resolvable on the caller's PATH (possibly overridden by env). host is the repo's GitLab hostname; when set the availability check is scoped to it via --hostname so a stale credential for an unrelated configured glab host cannot make this repo look unauthenticated. projectPath is the repo's "group/project" path (subgroups allowed); when set, pipeline-job reads go through `glab api` (REST), which is branch-independent and works in the daemon's detached-HEAD worktree, where `glab ci get` refuses to run without a current branch. Both are optional; empty reproduces the legacy unscoped behavior.

func (*Host) Available

func (h *Host) Available(ctx context.Context) error

func (*Host) Capabilities

func (h *Host) Capabilities() scm.Capabilities

func (*Host) CreatePR

func (h *Host) CreatePR(ctx context.Context, branch, base string, content scm.PRContent) (*scm.PR, error)

func (*Host) FetchFailedCheckLogs

func (h *Host) FetchFailedCheckLogs(ctx context.Context, pr *scm.PR, _ string, _ string, failingNames []string) (string, error)

func (*Host) FindPR

func (h *Host) FindPR(ctx context.Context, branch, base string) (*scm.PR, error)

func (*Host) GetChecks

func (h *Host) GetChecks(ctx context.Context, pr *scm.PR) ([]scm.Check, error)

func (*Host) GetMergeableState

func (h *Host) GetMergeableState(ctx context.Context, pr *scm.PR) (scm.MergeableState, error)

func (*Host) GetPRState

func (h *Host) GetPRState(ctx context.Context, pr *scm.PR) (scm.PRState, error)

func (*Host) Provider

func (h *Host) Provider() scm.Provider

func (*Host) UpdatePR

func (h *Host) UpdatePR(ctx context.Context, pr *scm.PR, content scm.PRContent) (*scm.PR, error)

Jump to

Keyboard shortcuts

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