Help us shape the future of Go! Take the 2026 Go Developer Survey

commitdiscussions

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package commitdiscussions implements MCP tools for GitLab commit discussion operations.

The package wraps the GitLab Discussions API for commit threads:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionSpecs

func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec

ActionSpecs returns canonical specs for commit discussion actions.

func DeleteNote

func DeleteNote(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) error

DeleteNote deletes a commit discussion note.

func DeleteNoteOutput

func DeleteNoteOutput(ctx context.Context, client *gitlabclient.Client, input DeleteNoteInput) (toolutil.DeleteOutput, error)

DeleteNoteOutput deletes a commit discussion note and returns the canonical success message shape.

func FormatListMarkdownString

func FormatListMarkdownString(out ListOutput) string

FormatListMarkdownString renders commit discussion threads as a Markdown table, the collection shape: one row per thread with the author of its first note and how many notes it holds. The heading counts what the response vouches for rather than the length of the page, and the pagination footer is written after the rows by the shared footer.

func FormatMarkdownString

func FormatMarkdownString(d Output) string

FormatMarkdownString renders a discussion thread as a card: the thread's own fields first, then one section per note, each with the author, the time, the position of a diff note and the body quoted under its label.

func FormatNoteMarkdownString

func FormatNoteMarkdownString(n NoteOutput) string

FormatNoteMarkdownString renders a single discussion note as a card: the author as a handle, the time, the flags that hold, the resolution state of a note that can carry one, the diff position of a note on a line, and the body as the card's long text. A note that is not resolvable shows no resolution state, where the card used to print "Resolved: false" for every note in a domain whose notes cannot be resolved at all.

Types

type AddNoteInput

type AddNoteInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	CommitSHA    string               `json:"commit_sha" jsonschema:"Commit SHA,required"`
	DiscussionID string               `json:"discussion_id" jsonschema:"Discussion ID to reply to,required"`
	Body         string               `json:"body" jsonschema:"Note body (Markdown supported),required"`
	// CreatedAt backdates the note; requires admin or project/group owner rights (ISO 8601).
	CreatedAt string `` /* 142-byte string literal not displayed */
}

AddNoteInput defines parameters for adding a note to a commit discussion. It mirrors gl.AddCommitDiscussionNoteOptions (body, created_at).

type CreateInput

type CreateInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	CommitSHA string               `json:"commit_sha" jsonschema:"Commit SHA,required"`
	Body      string               `json:"body" jsonschema:"Discussion body (Markdown supported),required"`
	Position  *PositionInput       `json:"position,omitempty" jsonschema:"Position for inline diff comments"`
	// CreatedAt backdates the discussion's first note; requires admin or project/group owner rights (ISO 8601).
	CreatedAt string `` /* 148-byte string literal not displayed */
}

CreateInput defines parameters for creating a commit discussion. It mirrors gl.CreateCommitDiscussionOptions (body, position, created_at).

type DeleteNoteInput

type DeleteNoteInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	CommitSHA    string               `json:"commit_sha" jsonschema:"Commit SHA,required"`
	DiscussionID string               `json:"discussion_id" jsonschema:"Discussion ID,required"`
	NoteID       int64                `json:"note_id" jsonschema:"Note ID to delete,required"`
}

DeleteNoteInput defines parameters for deleting a commit discussion note.

type GetInput

type GetInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	CommitSHA    string               `json:"commit_sha" jsonschema:"Commit SHA,required"`
	DiscussionID string               `json:"discussion_id" jsonschema:"Discussion ID,required"`
}

GetInput defines parameters for getting a single commit discussion.

type LinePositionInput

type LinePositionInput struct {
	LineCode string `json:"line_code,omitempty" jsonschema:"Line code identifying this line in the diff."`
	Type     string `` /* 137-byte string literal not displayed */
	OldLine  int64  `json:"old_line,omitempty"  jsonschema:"Line number in the old file for this endpoint."`
	NewLine  int64  `json:"new_line,omitempty"  jsonschema:"Line number in the new file for this endpoint."`
}

LinePositionInput mirrors gl.LinePosition: one endpoint (start or end) of a multi-line diff comment range.

type LineRangeInput

type LineRangeInput struct {
	Start *LinePositionInput `json:"start,omitempty" jsonschema:"Start endpoint of a multi-line diff comment range."`
	End   *LinePositionInput `json:"end,omitempty"   jsonschema:"End endpoint of a multi-line diff comment range."`
}

LineRangeInput mirrors gl.LineRange: the start/end endpoints of a multi-line diff comment position.

type ListInput

type ListInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	CommitSHA string               `json:"commit_sha" jsonschema:"Commit SHA,required"`
	// OrderBy names the column used to order keyset-paginated results.
	OrderBy string `json:"order_by,omitempty" jsonschema:"Column to order keyset-paginated results by (e.g. created_at, updated_at)"`
	// Sort selects the sort direction for ordered results.
	Sort string `json:"sort,omitempty" jsonschema:"Sort direction (asc or desc)"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

ListInput defines parameters for listing commit discussions. It mirrors gl.ListCommitDiscussionsOptions (which embeds gl.ListOptions), exposing keyset pagination (order_by, sort, pagination, page_token) in addition to offset pagination (1:1 audit P3).

type ListOutput

type ListOutput struct {
	toolutil.HintableOutput
	Discussions []Output                  `json:"discussions"`
	Pagination  toolutil.PaginationOutput `json:"pagination"`
}

ListOutput holds a list of commit discussions.

func List

func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)

List lists commit discussions. It mirrors gl.ListCommitDiscussionsOptions, applying offset and keyset pagination through toolutil.ApplyListOptions.

type NoteOutput

NoteOutput is a note of a commit discussion: a type of its own over toolutil.DiscussionThreadNoteOutput, the rich note shape the four REST discussion packages share, whose fields and JSON tags (UpdatedAt with omitempty, Resolved and Resolvable without) are defined there. It is a defined type rather than an alias because the Markdown registry is keyed by type: while the four packages aliased one, this package's card rendered every merge request, issue and snippet thread too, offering commit discussion actions as their next steps (issue 1291).

func AddNote

func AddNote(ctx context.Context, client *gitlabclient.Client, input AddNoteInput) (NoteOutput, error)

AddNote adds a note to an existing commit discussion.

func NoteToOutput

func NoteToOutput(n *gl.Note, extra toolutil.NoteExtra) NoteOutput

NoteToOutput converts a GitLab API gl.Note, and what the captured response adds to it, to a NoteOutput: the shared conversion in toolutil.DiscussionThreadNoteOutputFromGitLab, kept under the package's name for its callers and tests.

func UpdateNote

func UpdateNote(ctx context.Context, client *gitlabclient.Client, input UpdateNoteInput) (NoteOutput, error)

UpdateNote updates an existing commit discussion note.

type Output

Output is a commit discussion thread: a type of its own over toolutil.DiscussionThreadOutput, the thread shape with full note payloads, for the reason NoteOutput gives.

func Create

func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)

Create creates a new commit discussion thread.

func Get

func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (Output, error)

Get gets a single commit discussion.

func ToOutput

func ToOutput(d *gl.Discussion, extra toolutil.DiscussionExtra) Output

ToOutput converts a GitLab API gl.Discussion, and what the captured response adds to it, to an Output, including all notes within the thread.

type PositionInput

type PositionInput struct {
	BaseSHA      string          `json:"base_sha" jsonschema:"Base commit SHA,required"`
	StartSHA     string          `json:"start_sha" jsonschema:"Start commit SHA,required"`
	HeadSHA      string          `json:"head_sha" jsonschema:"Head commit SHA,required"`
	PositionType string          `` /* 154-byte string literal not displayed */
	NewPath      string          `json:"new_path,omitempty" jsonschema:"File path after change"`
	NewLine      int64           `json:"new_line,omitempty" jsonschema:"Line number after change"`
	OldPath      string          `json:"old_path,omitempty" jsonschema:"File path before change"`
	OldLine      int64           `json:"old_line,omitempty" jsonschema:"Line number before change"`
	LineRange    *LineRangeInput `json:"line_range,omitempty" jsonschema:"Start/end line range for a multi-line text diff comment."`
}

PositionInput defines position attributes for inline commit discussions. It mirrors gl.NotePosition in full — the position struct accepted by gl.CreateCommitDiscussionOptions.Position. Commit-thread positions are text (line) positions only; gl.NotePosition has no image (width/height/x/y) fields, so none are surfaced here (1:1 audit: no invented fields).

type UpdateNoteInput

type UpdateNoteInput struct {
	ProjectID    toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	CommitSHA    string               `json:"commit_sha" jsonschema:"Commit SHA,required"`
	DiscussionID string               `json:"discussion_id" jsonschema:"Discussion ID,required"`
	NoteID       int64                `json:"note_id" jsonschema:"Note ID to update,required"`
	Body         string               `json:"body" jsonschema:"Updated note body,required"`
	// CreatedAt overrides the note's creation timestamp; requires admin or project/group owner rights (ISO 8601).
	CreatedAt string `` /* 142-byte string literal not displayed */
}

UpdateNoteInput defines parameters for updating a commit discussion note. It mirrors gl.UpdateCommitDiscussionNoteOptions (body, created_at).

Jump to

Keyboard shortcuts

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