Documentation
¶
Overview ¶
Package gitlab implements forge.Forge for gitlab.com using the GitLab REST API. Uses net/http directly; no extra dependencies.
Index ¶
- type Client
- func (c *Client) BranchCompareURL(remoteURL, branch string) string
- func (c *Client) CIHomeURL(remoteURL string) string
- func (c *Client) CIJobURL(owner, repo string, _, jobID int64) string
- func (c *Client) CreatePR(ctx context.Context, owner, repo, head, base, title, body string) (forge.PR, error)
- func (c *Client) FindPRByBranch(ctx context.Context, owner, repo, sourceBranch string) (forge.PR, error)
- func (c *Client) GetCheckRuns(ctx context.Context, owner, repo, sha string) ([]forge.CheckRun, error)
- func (c *Client) GetDefaultBranchSHA(ctx context.Context, owner, repo, branch string) (string, error)
- func (c *Client) GetJobLabels(_ context.Context, _, _ string, _ int64) ([]string, error)
- func (c *Client) GetJobLog(ctx context.Context, owner, repo string, jobID int64, failingOnly bool) (log string, err error)
- func (c *Client) MergePR(ctx context.Context, owner, repo string, prNumber int, ...) error
- func (c *Client) Name() string
- func (c *Client) PRLabel(prNumber int) string
- func (c *Client) PRURL(owner, repo string, prNumber int) string
- type MergeRequestEvent
- type PipelineEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a minimal GitLab API client authenticated with a personal access token. It implements forge.Forge.
func NewClient ¶
func NewClient(token string, throttle http.RoundTripper) *Client
NewClient returns a Client that authenticates with token and throttles/retries via throttle. The transport chain is: Header → Retry → throttle.
func (*Client) BranchCompareURL ¶
BranchCompareURL returns the GitLab compare URL for a branch.
func (*Client) CreatePR ¶
func (c *Client) CreatePR(ctx context.Context, owner, repo, head, base, title, body string) (forge.PR, error)
CreatePR creates a merge request on GitLab and returns its metadata.
func (*Client) FindPRByBranch ¶
func (c *Client) FindPRByBranch(ctx context.Context, owner, repo, sourceBranch string) (forge.PR, error)
FindPRByBranch returns the MR for the given source branch, or ErrNotFound if no MR exists for that branch.
func (*Client) GetCheckRuns ¶
func (c *Client) GetCheckRuns(ctx context.Context, owner, repo, sha string) ([]forge.CheckRun, error)
GetCheckRuns returns all CI pipeline job statuses for the given commit SHA.
func (*Client) GetDefaultBranchSHA ¶
func (c *Client) GetDefaultBranchSHA(ctx context.Context, owner, repo, branch string) (string, error)
GetDefaultBranchSHA returns the HEAD commit SHA of branch in the given repo.
func (*Client) GetJobLabels ¶
GetJobLabels returns nil for GitLab; the commit statuses API does not expose job labels.
func (*Client) GetJobLog ¶
func (c *Client) GetJobLog(ctx context.Context, owner, repo string, jobID int64, failingOnly bool) (log string, err error)
GetJobLog fetches the log for a GitLab CI job, capped at 100 MB. failingOnly selects bounded head/tail context: GitLab traces do not include reliable step-level markers. Full retrieval keeps the existing download cap.
func (*Client) MergePR ¶
func (c *Client) MergePR(ctx context.Context, owner, repo string, prNumber int, commitTitle, commitMessage string) error
MergePR squash-merges a merge request on GitLab.
type MergeRequestEvent ¶ added in v0.8.0
type MergeRequestEvent struct {
ObjectAttributes struct {
IID int `json:"iid"`
State string `json:"state"` // "opened", "closed", "merged"
Merged bool `json:"merged"`
Title string `json:"title"`
Body string `json:"description"`
HeadBranch string `json:"head_branch"`
BaseBranch string `json:"base_branch"`
HeadSHA string `json:"head_sha"`
URL string `json:"url"`
} `json:"object_attributes"`
Project struct {
PathWithNamespace string `json:"path_with_namespace"` // "group/repo"
} `json:"project"`
Repository struct {
FullName string `json:"full_name"` // "group/repo" (may be empty; use Project)
} `json:"repository"`
}
MergeRequestEvent is the payload for X-Gitlab-Event: Merge Request Hook.
type PipelineEvent ¶
type PipelineEvent struct {
ObjectAttributes struct {
SHA string `json:"sha"`
Status string `json:"status"` // "success", "failed", "canceled", "skipped"
ID int64 `json:"id"`
} `json:"object_attributes"`
Project struct {
PathWithNamespace string `json:"path_with_namespace"` // "group/repo"
} `json:"project"`
}
PipelineEvent is the payload for X-Gitlab-Event: Pipeline Hook.