Documentation
¶
Overview ¶
Package gitlab implements scm.Host backed by the glab CLI.
Index ¶
- func ProjectPath(raw string) string
- type CmdFactory
- type Host
- func (h *Host) Available(ctx context.Context) error
- func (h *Host) Capabilities() scm.Capabilities
- func (h *Host) CreatePR(ctx context.Context, branch, base string, content scm.PRContent) (*scm.PR, error)
- func (h *Host) FetchFailedCheckLogs(ctx context.Context, pr *scm.PR, _ string, _ string, failingNames []string) (string, error)
- func (h *Host) FindPR(ctx context.Context, branch, base string) (*scm.PR, error)
- func (h *Host) GetChecks(ctx context.Context, pr *scm.PR) ([]scm.Check, error)
- func (h *Host) GetMergeableState(ctx context.Context, pr *scm.PR) (scm.MergeableState, error)
- func (h *Host) GetPRState(ctx context.Context, pr *scm.PR) (scm.PRState, error)
- func (h *Host) Provider() scm.Provider
- func (h *Host) UpdatePR(ctx context.Context, pr *scm.PR, content scm.PRContent) (*scm.PR, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProjectPath ¶
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 ¶
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) Capabilities ¶
func (h *Host) Capabilities() scm.Capabilities