gitlab

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadIndex

func LoadIndex() (*models.GitLabIndex, error)

func SaveIndex

func SaveIndex(idx *models.GitLabIndex) error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url, token string) (*Client, error)

func (*Client) AddMergeRequestDiscussionReply

func (c *Client) AddMergeRequestDiscussionReply(projectID any, mrIID int, discussionID, body string) error

AddMergeRequestDiscussionReply adds a reply to an existing discussion thread

func (*Client) ApproveMergeRequest

func (c *Client) ApproveMergeRequest(projectID any, mrIID int) error

ApproveMergeRequest approves a merge request

func (*Client) CloseMergeRequest

func (c *Client) CloseMergeRequest(projectID any, mrIID int) error

CloseMergeRequest closes a merge request

func (*Client) CreateMergeRequest

func (c *Client) CreateMergeRequest(projectID any, opts CreateMergeRequestOptions) (*models.MergeRequestDetail, error)

CreateMergeRequest creates a new merge request and returns its details

func (*Client) CreateMergeRequestInlineComment

func (c *Client) CreateMergeRequestInlineComment(projectID any, mrIID int, opts InlineCommentOptions) error

CreateMergeRequestInlineComment creates an inline comment on a specific file/line

func (*Client) CreateMergeRequestNote

func (c *Client) CreateMergeRequestNote(projectID any, mrIID int, body string) error

CreateMergeRequestNote adds a comment/note to a merge request

func (*Client) CreateMergeRequestNoteReaction

func (c *Client) CreateMergeRequestNoteReaction(projectID any, mrIID int, noteID int, emoji string) error

CreateMergeRequestNoteReaction adds an emoji reaction to a note/comment on a merge request

func (*Client) CreateMergeRequestReaction

func (c *Client) CreateMergeRequestReaction(projectID any, mrIID int, emoji string) error

CreateMergeRequestReaction adds an emoji reaction to a merge request

func (*Client) GetActiveProjects

func (c *Client) GetActiveProjects(since time.Time) ([]*gitlab.Project, error)

func (*Client) GetCommit

func (c *Client) GetCommit(projectID interface{}, sha string) (*models.CommitDetail, error)

GetCommit fetches detailed information about a single commit

func (*Client) GetCommits

func (c *Client) GetCommits(projectID int, since time.Time) ([]models.Commit, error)

func (*Client) GetMergeRequest

func (c *Client) GetMergeRequest(projectID interface{}, mrIID int) (*models.MergeRequestDetail, error)

GetMergeRequest fetches a single merge request with full details

func (*Client) GetMergeRequestChanges

func (c *Client) GetMergeRequestChanges(projectID any, mrIID int, includeDiff bool) ([]models.MRFile, error)

GetMergeRequestChanges fetches the list of files changed in a merge request

func (*Client) GetMergeRequestCommits

func (c *Client) GetMergeRequestCommits(projectID any, mrIID int) ([]models.MRCommit, error)

GetMergeRequestCommits fetches commits associated with a merge request

func (*Client) GetMergeRequestDiffVersions

func (c *Client) GetMergeRequestDiffVersions(projectID any, mrIID int) (*models.MRDiffVersion, error)

GetMergeRequestDiffVersions fetches the diff version info needed for inline comments

func (*Client) GetMergeRequestDiscussions

func (c *Client) GetMergeRequestDiscussions(projectID any, mrIID int) ([]models.MRDiscussion, error)

GetMergeRequestDiscussions fetches all discussions/threads on a merge request

func (*Client) GetMergeRequestNotes

func (c *Client) GetMergeRequestNotes(projectID any, mrIID int) ([]models.MRNote, error)

GetMergeRequestNotes fetches all notes/comments on a merge request

func (*Client) GetMergeRequests

func (c *Client) GetMergeRequests(projectID int, since time.Time) ([]models.MergeRequest, error)

func (*Client) GetParsedDiffForFile added in v0.9.0

func (c *Client) GetParsedDiffForFile(projectID any, mrIID int, filePath string) (*ParsedDiff, error)

GetParsedDiffForFile fetches and parses the diff for a specific file in an MR

func (*Client) GetProjectMetadata

func (c *Client) GetProjectMetadata(idOrPath string) (*models.ProjectMetadata, error)

func (*Client) GetTags

func (c *Client) GetTags(projectID int, since time.Time) ([]models.Tag, error)

func (*Client) IndexAllProjects

func (c *Client) IndexAllProjects(gitlabURL string, progressFn ProgressFunc) (*models.GitLabIndex, error)

func (*Client) ListMergeRequests

func (c *Client) ListMergeRequests(opts ListMergeRequestsOptions) ([]models.MergeRequestDetail, error)

ListMergeRequests fetches merge requests based on options

func (*Client) ListProjects

func (c *Client) ListProjects(opts ListProjectsOptions) ([]*gitlab.Project, error)

ListProjects returns projects with configurable sorting and limit

func (*Client) MergeMergeRequest

func (c *Client) MergeMergeRequest(projectID any, mrIID int, opts MergeMergeRequestOptions) error

MergeMergeRequest merges (accepts) a merge request

func (*Client) TestAuth added in v0.3.0

func (c *Client) TestAuth() (*gitlab.User, error)

TestAuth verifies the token works and returns current user info

type CreateMergeRequestOptions

type CreateMergeRequestOptions struct {
	Title              string
	Description        string
	SourceBranch       string
	TargetBranch       string
	Draft              bool
	RemoveSourceBranch bool
	Squash             bool
}

CreateMergeRequestOptions contains options for creating a merge request

type DiffLine added in v0.9.0

type DiffLine struct {
	Type    LineType
	OldLine int    // 0 if line doesn't exist in old version (added lines)
	NewLine int    // 0 if line doesn't exist in new version (deleted lines)
	Content string // Line content without the prefix
}

DiffLine represents a line in a parsed diff

type InlineCommentOptions

type InlineCommentOptions struct {
	Body    string
	NewPath string
	OldPath string
	NewLine int
	OldLine int
}

InlineCommentOptions contains options for creating an inline/diff comment

type LineType added in v0.9.0

type LineType int

LineType represents the type of line in a diff

const (
	LineContext LineType = iota // Unchanged line (space prefix)
	LineAdded                   // Added line (+ prefix)
	LineDeleted                 // Deleted line (- prefix)
)

func (LineType) String added in v0.13.0

func (lt LineType) String() string

LineTypeString returns a human-readable string for a line type

type ListMergeRequestsOptions

type ListMergeRequestsOptions struct {
	State         string // opened, closed, merged, all
	Scope         string // created_by_me, assigned_to_me, all
	Limit         int
	OrderBy       string // created_at, updated_at
	Sort          string // asc, desc
	ProjectID     string // optional - filter to specific project
	IncludeWIP    bool   // include WIP/draft MRs (excluded by default)
	ConflictsOnly bool   // only show MRs with conflicts
}

ListMergeRequestsOptions configures the MR list query

type ListProjectsOptions

type ListProjectsOptions struct {
	Limit   int    // Maximum number of projects to return (0 = all)
	OrderBy string // Sort field: "created_at", "last_activity_at", "name", "path", "id"
	Sort    string // Sort direction: "asc" or "desc"
}

ListProjectsOptions configures the ListProjects call

type MergeMergeRequestOptions

type MergeMergeRequestOptions struct {
	Squash                    bool
	RemoveSourceBranch        bool
	MergeWhenPipelineSucceeds bool
	MergeCommitMessage        string
	SquashCommitMessage       string
}

MergeMergeRequestOptions contains options for merging a merge request

type ParsedDiff added in v0.9.0

type ParsedDiff struct {
	OldPath string
	NewPath string
	Lines   []DiffLine
}

ParsedDiff contains parsed diff information for a file

func ParseUnifiedDiff added in v0.9.0

func ParseUnifiedDiff(diff string) *ParsedDiff

ParseUnifiedDiff parses a unified diff string into structured data

func (*ParsedDiff) FindLineByNew added in v0.9.0

func (p *ParsedDiff) FindLineByNew(newLine int) (*DiffLine, bool)

FindLineByNew finds a line by its new line number Returns the DiffLine and whether it was found

func (*ParsedDiff) FindLineByOld added in v0.9.0

func (p *ParsedDiff) FindLineByOld(oldLine int) (*DiffLine, bool)

FindLineByOld finds a line by its old line number Returns the DiffLine and whether it was found

func (*ParsedDiff) GetLineWithContext added in v0.13.0

func (p *ParsedDiff) GetLineWithContext(newLine int, contextLines int) (target *DiffLine, before []DiffLine, after []DiffLine)

GetLineWithContext returns a line and its surrounding context lines contextLines specifies how many lines before and after to include

func (*ParsedDiff) SearchLines added in v0.13.0

func (p *ParsedDiff) SearchLines(pattern string) ([]DiffLine, error)

SearchLines searches for lines matching a regex pattern Returns matching lines with their indices

type ProgressFunc

type ProgressFunc func(completed, total int)

Jump to

Keyboard shortcuts

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