mrchanges

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package mrchanges implements MCP tools for GitLab merge request changes and diff operations.

The package wraps the GitLab Merge requests API changes endpoints:

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 merge request changes and diff version actions.

func FormatDiffVersionGetMarkdown

func FormatDiffVersionGetMarkdown(out DiffVersionOutput) string

FormatDiffVersionGetMarkdown renders a single diff version detail as markdown.

func FormatDiffVersionsListMarkdown

func FormatDiffVersionsListMarkdown(out DiffVersionsListOutput) string

FormatDiffVersionsListMarkdown renders the list of diff versions as markdown.

func FormatOutputMarkdown

func FormatOutputMarkdown(out Output) string

FormatOutputMarkdown renders the list of file changes in a merge request.

func FormatRawDiffsMarkdown

func FormatRawDiffsMarkdown(out RawDiffsOutput) string

FormatRawDiffsMarkdown renders the raw diff output as a fenced code block.

Types

type CommitStatsOutput added in v2.3.0

type CommitStatsOutput struct {
	Additions int64 `json:"additions"`
	Deletions int64 `json:"deletions"`
	Total     int64 `json:"total"`
}

CommitStatsOutput mirrors gl.CommitStats: line additions/deletions for a commit.

type DiffVersionCommitOutput

type DiffVersionCommitOutput struct {
	ID               string             `json:"id"`
	ShortID          string             `json:"short_id"`
	Title            string             `json:"title"`
	AuthorName       string             `json:"author_name"`
	AuthorEmail      string             `json:"author_email,omitempty"`
	AuthoredDate     string             `json:"authored_date,omitempty"`
	CommitterName    string             `json:"committer_name,omitempty"`
	CommitterEmail   string             `json:"committer_email,omitempty"`
	CommittedDate    string             `json:"committed_date,omitempty"`
	CreatedAt        string             `json:"created_at,omitempty"`
	Message          string             `json:"message,omitempty"`
	ParentIDs        []string           `json:"parent_ids,omitempty"`
	Stats            *CommitStatsOutput `json:"stats,omitempty"`
	Status           string             `json:"status,omitempty"`
	ProjectID        int64              `json:"project_id,omitempty"`
	Trailers         map[string]string  `json:"trailers,omitempty"`
	ExtendedTrailers map[string]string  `json:"extended_trailers,omitempty"`
	WebURL           string             `json:"web_url,omitempty"`
}

DiffVersionCommitOutput is a full local mirror of gl.Commit (C-IMPORTS): every field returned by the GitLab commit payload inside a diff version is surfaced here.

type DiffVersionGetInput

type DiffVersionGetInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id"  jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_iid"      jsonschema:"Merge request internal ID,required"`
	VersionID int64                `json:"version_id"  jsonschema:"Diff version ID,required"`
	Unidiff   bool                 `json:"unidiff,omitempty" jsonschema:"Return diffs in unified diff format (default: false)"`
}

DiffVersionGetInput defines parameters for getting a single MR diff version.

type DiffVersionOutput

type DiffVersionOutput struct {
	toolutil.HintableOutput
	ID             int64                     `json:"id"`
	HeadCommitSHA  string                    `json:"head_commit_sha,omitempty"`
	BaseCommitSHA  string                    `json:"base_commit_sha,omitempty"`
	StartCommitSHA string                    `json:"start_commit_sha,omitempty"`
	CreatedAt      string                    `json:"created_at,omitempty"`
	MergeRequestID int64                     `json:"merge_request_id,omitempty"`
	State          string                    `json:"state,omitempty"`
	RealSize       string                    `json:"real_size,omitempty"`
	Commits        []DiffVersionCommitOutput `json:"commits,omitempty"`
	Diffs          []FileDiffOutput          `json:"diffs,omitempty"`
}

DiffVersionOutput represents a single merge request diff version.

func GetDiffVersion

func GetDiffVersion(ctx context.Context, client *gitlabclient.Client, input DiffVersionGetInput) (DiffVersionOutput, error)

GetDiffVersion retrieves a single diff version with its commits and diffs.

type DiffVersionsListInput

type DiffVersionsListInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_iid"     jsonschema:"Merge request internal ID,required"`
	OrderBy   string               `json:"order_by,omitempty" jsonschema:"For keyset pagination, the column to order results by"`
	Sort      string               `json:"sort,omitempty" jsonschema:"Sort order for keyset pagination: 'asc' or 'desc'"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

DiffVersionsListInput defines parameters for listing MR diff versions.

type DiffVersionsListOutput

type DiffVersionsListOutput struct {
	toolutil.HintableOutput
	DiffVersions []DiffVersionOutput       `json:"diff_versions"`
	Pagination   toolutil.PaginationOutput `json:"pagination"`
}

DiffVersionsListOutput holds the paginated list of diff versions.

func ListDiffVersions

func ListDiffVersions(ctx context.Context, client *gitlabclient.Client, input DiffVersionsListInput) (DiffVersionsListOutput, error)

ListDiffVersions retrieves the list of diff versions for a merge request.

type FileDiffOutput

type FileDiffOutput struct {
	OldPath       string `json:"old_path"`
	NewPath       string `json:"new_path"`
	Diff          string `json:"diff"`
	NewFile       bool   `json:"new_file"`
	RenamedFile   bool   `json:"renamed_file"`
	DeletedFile   bool   `json:"deleted_file"`
	AMode         string `json:"a_mode"`
	BMode         string `json:"b_mode"`
	GeneratedFile bool   `json:"generated_file"`
	Collapsed     bool   `json:"collapsed,omitempty"`
	TooLarge      bool   `json:"too_large,omitempty"`
}

FileDiffOutput represents a single file diff in a merge request.

func DiffToOutput

func DiffToOutput(d *gl.MergeRequestDiff) FileDiffOutput

DiffToOutput converts a GitLab API gl.MergeRequestDiff to the MCP tool output format, preserving file paths, diff content, and file mode metadata.

type GetInput

type GetInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_iid"     jsonschema:"Merge request internal ID,required"`
	Unidiff   bool                 `json:"unidiff,omitempty" jsonschema:"Return diffs in unified diff format (default: false)"`
	OrderBy   string               `json:"order_by,omitempty" jsonschema:"For keyset pagination, the column to order results by"`
	Sort      string               `json:"sort,omitempty" jsonschema:"Sort order for keyset pagination: 'asc' or 'desc'"`
	toolutil.PaginationInput
	toolutil.KeysetPaginationInput
}

GetInput defines parameters for listing changed files in a merge request.

type Output

type Output struct {
	toolutil.HintableOutput
	MRIID          int64            `json:"merge_request_iid"`
	Changes        []FileDiffOutput `json:"changes"`
	TruncatedFiles []string         `json:"truncated_files,omitempty"`
}

Output holds the list of file diffs for a merge request.

func Get

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

Get retrieves the list of file diffs for a merge request by calling the GitLab Merge Request Diffs API. Returns all changed files with their diff content, old/new paths, and file status flags.

type RawDiffsInput

type RawDiffsInput struct {
	ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
	MRIID     int64                `json:"merge_request_iid"     jsonschema:"Merge request internal ID,required"`
}

RawDiffsInput defines parameters for retrieving raw diffs of a merge request.

type RawDiffsOutput

type RawDiffsOutput struct {
	toolutil.HintableOutput
	MRIID   int64  `json:"merge_request_iid"`
	RawDiff string `json:"raw_diff"`
}

RawDiffsOutput holds the raw unified-diff output for a merge request.

func RawDiffs

func RawDiffs(ctx context.Context, client *gitlabclient.Client, input RawDiffsInput) (RawDiffsOutput, error)

RawDiffs retrieves the raw diff content for a merge request. The response is a plain-text unified diff that can be applied with git-apply(1).

Jump to

Keyboard shortcuts

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