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 ¶
- Variables
- func Fetch(ref Ref, isLockfile func(path string) bool) (*ghpr.Result, error)
- func FetchCompare(ref CmpRef, isLockfile func(path string) bool) (*ghpr.Result, error)
- func HasToken() bool
- func ParseCommit(s string) (host, project, sha string, ok bool)
- func PostComment(ref Ref, body string) (noteURL string, updated bool, err error)
- type CmpRef
- type QueueItem
- type Ref
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
ParseCommit recognises a GitLab commit URL:
https://gitlab.com/GROUP/PROJECT/-/commit/SHA
func PostComment ¶ added in v0.1.7
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 ¶
CmpRef identifies a comparison between two revisions of a GitLab project.
func ParseCompare ¶
ParseCompare recognises a GitLab compare URL:
https://gitlab.com/GROUP/PROJECT/-/compare/BASE...HEAD
func ResolveCommit ¶
ResolveCommit turns HOST/PROJECT + SHA into the CmpRef parent...sha, so a single commit can be vetted with FetchCompare.
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
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.