glmr

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package glmr fetches the lockfile changes of a GitLab merge request (or comparison / commit) via the REST API, so it can be vetted without cloning the repository. Works with gitlab.com and self-hosted instances.

Index

Constants

This section is empty.

Variables

View Source
var DefaultQueueAuthors = []string{"renovate-bot", "dependabot"}

DefaultQueueAuthors are the bot usernames queried when the user doesn't pass -author. GitLab bot identities vary per instance (e.g. gitlab-org's Renovate runs as gitlab-dependency-update-bot), so custom bots need an explicit -author.

Functions

func Fetch

func Fetch(ref Ref, isLockfile func(path string) bool) (*ghpr.Result, error)

Fetch downloads the MR metadata and the before/after contents of every changed file isLockfile accepts. Both sides are read from the target project: GitLab keeps MR head commits reachable there even for fork MRs. Authenticates with GITLAB_TOKEN / GL_TOKEN (or CI_JOB_TOKEN inside GitLab CI) when set; works unauthenticated on public projects.

func FetchCompare

func FetchCompare(ref CmpRef, isLockfile func(path string) bool) (*ghpr.Result, error)

FetchCompare downloads the file changes between two revisions via the GitLab compare API (merge-base semantics by default, like an MR diff) and returns the before/after contents of every changed file isLockfile accepts.

func HasToken added in v0.1.14

func HasToken() bool

HasToken reports whether a GitLab token is available in the environment.

func ParseCommit

func ParseCommit(s string) (host, project, sha string, ok bool)

ParseCommit recognises a GitLab commit URL:

https://gitlab.com/GROUP/PROJECT/-/commit/SHA

func PostComment added in v0.1.7

func PostComment(ref Ref, body string) (noteURL string, updated bool, err error)

PostComment creates — or, if a lockvet note already exists, updates — the report note on a merge request. Returns the note's web URL and whether an existing note was updated. Requires GITLAB_TOKEN / GL_TOKEN with api scope (CI_JOB_TOKEN cannot use the notes API).

Types

type CmpRef

type CmpRef struct {
	Host    string
	Project string
	Base    string
	Head    string
}

CmpRef identifies a comparison between two revisions of a GitLab project.

func ParseCompare

func ParseCompare(s string) (CmpRef, bool)

ParseCompare recognises a GitLab compare URL:

https://gitlab.com/GROUP/PROJECT/-/compare/BASE...HEAD

func ResolveCommit

func ResolveCommit(host, project, sha string) (CmpRef, error)

ResolveCommit turns HOST/PROJECT + SHA into the CmpRef parent...sha, so a single commit can be vetted with FetchCompare.

func (CmpRef) String

func (r CmpRef) String() string

type QueueItem added in v0.1.14

type QueueItem struct {
	Ref     Ref
	Title   string
	Author  string
	URL     string // web_url
	Updated time.Time
}

QueueItem is one open dependency-update merge request found by ListQueue.

func ListQueue added in v0.1.14

func ListQueue(host, scope string, authors []string, limit int) ([]QueueItem, string, error)

ListQueue finds open merge requests by the given authors in scope, which is a project path ("group/project") or a group path ("group" or "group/subgroup"; subgroup projects are included). Authors may be empty to match every open MR. Results are most-recently-updated first, capped at limit. The returned string describes the scope (e.g. "group:gitlab-org") for display.

GitLab's author_username filter is single-valued, so one request (per page) is made for each author.

type Ref

type Ref struct {
	Host    string // e.g. "gitlab.com"
	Project string // full path, subgroups included: "group/sub/project"
	IID     int
}

Ref identifies a merge request.

func ParseMR

func ParseMR(s string) (Ref, bool)

ParseMR recognises a merge request reference in either form:

https://gitlab.com/GROUP/PROJECT/-/merge_requests/123  (any host)
GROUP/PROJECT!123                                      (gitlab.com)

func (Ref) String

func (r Ref) String() string

Jump to

Keyboard shortcuts

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