Documentation
¶
Overview ¶
Package gitlabx wraps the official GitLab client behind a small interface the TUI can depend on and tests can fake. It is the only package in the module that imports client-go.
Index ¶
- type Client
- func (c *Client) CreateDraftNote(ctx context.Context, project any, iid int64, body string, pos *Position) error
- func (c *Client) CreateInlineDiscussion(ctx context.Context, project any, iid int64, body string, pos *Position) error
- func (c *Client) CreateNote(ctx context.Context, project any, iid int64, body string) error
- func (c *Client) GetMergeRequest(ctx context.Context, project any, iid int64) (*MRDetail, error)
- func (c *Client) ListDiffs(ctx context.Context, project any, iid int64) ([]FileDiff, error)
- func (c *Client) ListDiscussions(ctx context.Context, project any, iid int64) ([]Discussion, error)
- func (c *Client) ListGroupProjects(ctx context.Context, group string, search string, page Page) ([]ProjectInfo, bool, error)
- func (c *Client) ListGroups(ctx context.Context, search string, page Page) ([]GroupInfo, bool, error)
- func (c *Client) ListMemberProjects(ctx context.Context, search string, page Page) ([]ProjectInfo, bool, error)
- func (c *Client) ListOpenMergeRequests(ctx context.Context, filter MRFilter, page Page) ([]MRSummary, bool, error)
- func (c *Client) PublishAllDraftNotes(ctx context.Context, project any, iid int64) error
- type DiffRefs
- type Discussion
- type FileDiff
- type GroupInfo
- type MRDetail
- type MRFilter
- type MRSummary
- type Note
- type Page
- type Position
- type ProjectInfo
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements Service against a real GitLab instance.
func New ¶
New builds a Client for the given instance. projects and groups are the full paths the MR list fans out over.
func (*Client) CreateDraftNote ¶
func (*Client) CreateInlineDiscussion ¶
func (*Client) CreateNote ¶
func (*Client) GetMergeRequest ¶
func (*Client) ListDiscussions ¶
func (*Client) ListGroupProjects ¶
func (*Client) ListGroups ¶
func (*Client) ListMemberProjects ¶
func (*Client) ListOpenMergeRequests ¶
type Discussion ¶
Discussion is a thread of notes on an MR.
func (Discussion) Anchor ¶
func (d Discussion) Anchor() *Position
Anchor returns the diff position of the discussion's first positioned note, or nil for general (unanchored) threads.
type FileDiff ¶
type FileDiff struct {
OldPath string
NewPath string
Diff string
NewFile bool
RenamedFile bool
DeletedFile bool
GeneratedFile bool
TooLarge bool
}
FileDiff is one file's unified diff within an MR.
type MRFilter ¶
type MRFilter struct {
State string // opened | merged | closed | all
AuthorUsername string
TargetBranch string
Search string
// Projects/Groups override the configured scope for this query (used
// by in-TUI selection). Both empty = use the configured scope.
Projects []string
Groups []string
}
MRFilter narrows the MR list. Zero values mean "no filter" except State, which defaults to opened.
type MRSummary ¶
type MRSummary struct {
ProjectID int64
ProjectPath string // full path with namespace; may be empty if unknown
IID int64
Title string
Description string
State string
Draft bool
Author string
SourceBranch string
TargetBranch string
HeadSHA string
WebURL string
CreatedAt time.Time
UpdatedAt time.Time
}
MRSummary is the list-view projection of a merge request.
type Note ¶
type Note struct {
ID int64
Author string
Body string
System bool
Resolved bool
CreatedAt time.Time
Position *Position // nil for general (unpositioned) notes
}
Note is a single comment, optionally anchored to a diff position.
type Position ¶
type Position struct {
BaseSHA string
HeadSHA string
StartSHA string
OldPath string
NewPath string
OldLine *int
NewLine *int
}
Position locates a comment on a diff, mapping 1:1 onto the GitLab API's text position type.
type ProjectInfo ¶
type ProjectInfo struct {
ID int64
PathWithNamespace string
Description string
LastActivity time.Time
}
ProjectInfo is a project the user can browse, for in-TUI selection.
type Service ¶
type Service interface {
// ListOpenMergeRequests returns one page of MRs merged across the
// scope (filter override or the configured projects and groups),
// newest-updated first, and whether any source has more pages.
ListOpenMergeRequests(ctx context.Context, filter MRFilter, page Page) ([]MRSummary, bool, error)
// ListGroups returns groups the user has access to, for in-TUI scope
// selection.
ListGroups(ctx context.Context, search string, page Page) ([]GroupInfo, bool, error)
// ListGroupProjects returns a group's projects (including subgroups).
ListGroupProjects(ctx context.Context, group string, search string, page Page) ([]ProjectInfo, bool, error)
// ListMemberProjects returns projects the user is a member of,
// covering personal and directly-shared projects outside any group.
ListMemberProjects(ctx context.Context, search string, page Page) ([]ProjectInfo, bool, error)
// GetMergeRequest fetches full MR details including diff refs.
// project is a full path (group/app) or numeric ID.
GetMergeRequest(ctx context.Context, project any, iid int64) (*MRDetail, error)
// ListDiffs returns every file diff of the MR (paginating internally).
ListDiffs(ctx context.Context, project any, iid int64) ([]FileDiff, error)
// ListDiscussions returns every discussion thread on the MR
// (paginating internally).
ListDiscussions(ctx context.Context, project any, iid int64) ([]Discussion, error)
// CreateInlineDiscussion posts a positioned comment on the MR diff.
CreateInlineDiscussion(ctx context.Context, project any, iid int64, body string, pos *Position) error
// CreateNote posts a general (unpositioned) comment on the MR — the
// fallback when no diff position can be resolved.
CreateNote(ctx context.Context, project any, iid int64, body string) error
// CreateDraftNote adds a comment to the user's pending review; pos may
// be nil for a general draft note. Nothing is visible to others until
// PublishAllDraftNotes.
CreateDraftNote(ctx context.Context, project any, iid int64, body string, pos *Position) error
// PublishAllDraftNotes publishes the pending review in one action.
PublishAllDraftNotes(ctx context.Context, project any, iid int64) error
}
Service is what the rest of the application sees of GitLab. Write operations (discussions, draft notes) join the interface with the review publishing milestone.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package position maps review findings onto GitLab diff positions: the base/head/start SHAs plus old/new path and line GitLab requires for an inline discussion.
|
Package position maps review findings onto GitLab diff positions: the base/head/start SHAs plus old/new path and line GitLab requires for an inline discussion. |