Documentation
¶
Overview ¶
Package gitlab provides GitLab API client operations.
Index ¶
- Variables
- type APIClient
- type Client
- func (c *Client) ApproveMergeRequest(mrIID int) error
- func (c *Client) CreateMergeRequest(sourceBranch, targetBranch, title, description, assignee, reviewer string, ...) (*gitlab.MergeRequest, error)
- func (c *Client) GetMergeRequestByBranch(sourceBranch, targetBranch string) (*gitlab.MergeRequest, error)
- func (c *Client) GetMergeRequestsByBranch(sourceBranch string) ([]*gitlab.BasicMergeRequest, error)
- func (c *Client) ListLabels() ([]*Label, error)
- func (c *Client) MergeMergeRequest(mrIID int, squash bool) error
- func (c *Client) SetLogger(logger *bullets.Logger)
- func (c *Client) SetProjectFromURL(url string) error
- func (c *Client) WaitForPipeline(timeout time.Duration) (string, error)
- type DisplayRenderer
- type Job
- type Label
- type StateTracker
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTokenRequired is returned when GITLAB_TOKEN environment variable is missing. ErrTokenRequired = errTokenRequired // ErrInvalidURLFormat is returned when the GitLab URL format is invalid. ErrInvalidURLFormat = errInvalidURLFormat // ErrAssigneeNotFound is returned when the assignee user cannot be found. ErrAssigneeNotFound = errAssigneeNotFound // ErrReviewerNotFound is returned when the reviewer user cannot be found. ErrReviewerNotFound = errReviewerNotFound // ErrPipelineTimeout is returned when waiting for pipeline completion times out. ErrPipelineTimeout = errPipelineTimeout // ErrMRNotFound is returned when no merge request is found for the branch. ErrMRNotFound = errMRNotFound )
Error definitions for GitLab API operations.
Functions ¶
This section is empty.
Types ¶
type APIClient ¶ added in v0.5.0
type APIClient interface {
// SetProjectFromURL configures the project from a git remote URL.
// Supports both HTTPS and SSH formats.
SetProjectFromURL(url string) error
// ListLabels returns all labels available in the project.
ListLabels() ([]*Label, error)
// CreateMergeRequest creates a new merge request with the specified parameters.
// Returns the created merge request or an error if creation fails.
CreateMergeRequest(
sourceBranch, targetBranch, title, description, assignee, reviewer string,
labels []string, squash bool,
) (*gitlab.MergeRequest, error)
// GetMergeRequestByBranch fetches an existing merge request by source and target branches.
// Returns errMRNotFound if no matching merge request exists.
GetMergeRequestByBranch(sourceBranch, targetBranch string) (*gitlab.MergeRequest, error)
// WaitForPipeline waits for all pipelines to complete for the merge request.
// Returns the overall status (success, failed, etc.) or an error on timeout.
WaitForPipeline(timeout time.Duration) (string, error)
// ApproveMergeRequest approves a merge request.
// Returns an error if the approval fails.
ApproveMergeRequest(mrIID int) error
// MergeMergeRequest merges a merge request with optional squash.
// Returns an error if the merge fails.
MergeMergeRequest(mrIID int, squash bool) error
// GetMergeRequestsByBranch returns all open merge requests for the given source branch.
GetMergeRequestsByBranch(sourceBranch string) ([]*gitlab.BasicMergeRequest, error)
}
APIClient defines the interface for GitLab API operations. This interface enables dependency injection and facilitates black box testing by allowing mock implementations to replace the actual GitLab API client.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a GitLab API client wrapper.
func (*Client) ApproveMergeRequest ¶
ApproveMergeRequest approves a merge request.
func (*Client) CreateMergeRequest ¶
func (c *Client) CreateMergeRequest( sourceBranch, targetBranch, title, description, assignee, reviewer string, labels []string, squash bool, ) (*gitlab.MergeRequest, error)
CreateMergeRequest creates a new merge request with assignees, reviewers, and labels.
func (*Client) GetMergeRequestByBranch ¶
func (c *Client) GetMergeRequestByBranch(sourceBranch, targetBranch string) (*gitlab.MergeRequest, error)
GetMergeRequestByBranch fetches an existing merge request by source and target branches.
func (*Client) GetMergeRequestsByBranch ¶
func (c *Client) GetMergeRequestsByBranch(sourceBranch string) ([]*gitlab.BasicMergeRequest, error)
GetMergeRequestsByBranch returns all open merge requests for the given source branch.
func (*Client) ListLabels ¶
ListLabels returns all labels for the project.
func (*Client) MergeMergeRequest ¶
MergeMergeRequest merges a merge request.
func (*Client) SetProjectFromURL ¶
SetProjectFromURL sets the project from a git remote URL.
type DisplayRenderer ¶ added in v0.5.0
type DisplayRenderer interface {
// Info logs an informational message.
Info(message string)
// Debug logs a debug message.
Debug(message string)
// Error logs an error message.
Error(message string)
// Success logs a success message.
Success(message string)
// InfoHandle creates an updatable handle for an info message.
// The handle can be updated with new content or converted to success/error.
InfoHandle(message string) *bullets.BulletHandle
// SpinnerCircle creates an animated spinner with the given message.
// Returns a Spinner that can be stopped with Success(), Error(), or Replace().
SpinnerCircle(message string) *bullets.Spinner
// IncreasePadding increases the indentation level for nested output.
IncreasePadding()
// DecreasePadding decreases the indentation level for nested output.
DecreasePadding()
}
DisplayRenderer defines the interface for UI rendering operations. This interface abstracts the bullets.Logger and bullets.UpdatableLogger functionality to enable testing of display logic without actual terminal output.
type Job ¶ added in v0.5.0
type Job struct {
ID int
Name string
Status string
Stage string
CreatedAt time.Time
StartedAt *time.Time
FinishedAt *time.Time
Duration float64
WebURL string
}
Job represents a GitLab pipeline job with detailed status information.
type StateTracker ¶ added in v0.5.0
type StateTracker interface {
// contains filtered or unexported methods
}
StateTracker defines the interface for thread-safe job state management. This interface abstracts the jobTracker functionality to enable testing of state transitions and display handle management without real API calls.