Documentation
¶
Overview ¶
Package commits implements GitLab commit operations including listing, getting, creating commits, retrieving diffs, refs, comments, statuses, merge requests by commit, cherry-pick, revert, and GPG signatures. It exposes typed input/output structs and handler functions registered as MCP tools.
Index ¶
- func FormatCommentMarkdown(c CommentOutput) string
- func FormatCommentsMarkdown(out CommentsOutput) string
- func FormatDetailMarkdown(c DetailOutput) string
- func FormatDiffMarkdown(out DiffOutput) string
- func FormatGPGSignatureMarkdown(sig GPGSignatureOutput) string
- func FormatListMarkdown(out ListOutput) string
- func FormatMRsByCommitMarkdown(out MRsByCommitOutput) string
- func FormatOutputMarkdown(c Output) string
- func FormatRefsMarkdown(out RefsOutput) string
- func FormatStatusMarkdown(s StatusOutput) string
- func FormatStatusesMarkdown(out StatusesOutput) string
- func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
- type Action
- type BasicMROutput
- type CherryPickInput
- type CommentOutput
- type CommentsInput
- type CommentsOutput
- type CreateInput
- type DetailOutput
- type DiffInput
- type DiffOutput
- type GPGSignatureInput
- type GPGSignatureOutput
- type GetInput
- type ListInput
- type ListOutput
- type MRsByCommitInput
- type MRsByCommitOutput
- type Output
- func CherryPick(ctx context.Context, client *gitlabclient.Client, input CherryPickInput) (Output, error)
- func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)
- func Revert(ctx context.Context, client *gitlabclient.Client, input RevertInput) (Output, error)
- func ToOutput(c *gl.Commit) Output
- type PostCommentInput
- type RefOutput
- type RefsInput
- type RefsOutput
- type RevertInput
- type SetStatusInput
- type StatsOutput
- type StatusOutput
- type StatusesInput
- type StatusesOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCommentMarkdown ¶
func FormatCommentMarkdown(c CommentOutput) string
FormatCommentMarkdown renders a single commit comment.
func FormatCommentsMarkdown ¶
func FormatCommentsMarkdown(out CommentsOutput) string
FormatCommentsMarkdown renders a paginated list of commit comments.
func FormatDetailMarkdown ¶
func FormatDetailMarkdown(c DetailOutput) string
FormatDetailMarkdown renders a single commit detail as a Markdown summary.
func FormatDiffMarkdown ¶
func FormatDiffMarkdown(out DiffOutput) string
FormatDiffMarkdown renders a paginated list of commit diffs as a Markdown table.
func FormatGPGSignatureMarkdown ¶
func FormatGPGSignatureMarkdown(sig GPGSignatureOutput) string
FormatGPGSignatureMarkdown renders a GPG signature as Markdown.
func FormatListMarkdown ¶
func FormatListMarkdown(out ListOutput) string
FormatListMarkdown renders a paginated list of commits as a Markdown table.
func FormatMRsByCommitMarkdown ¶
func FormatMRsByCommitMarkdown(out MRsByCommitOutput) string
FormatMRsByCommitMarkdown renders a list of merge requests for a commit.
func FormatOutputMarkdown ¶
FormatOutputMarkdown renders a single commit as a Markdown summary.
func FormatRefsMarkdown ¶
func FormatRefsMarkdown(out RefsOutput) string
FormatRefsMarkdown renders a paginated list of commit refs as Markdown.
func FormatStatusMarkdown ¶
func FormatStatusMarkdown(s StatusOutput) string
FormatStatusMarkdown renders a single commit status.
func FormatStatusesMarkdown ¶
func FormatStatusesMarkdown(out StatusesOutput) string
FormatStatusesMarkdown renders a paginated list of commit statuses.
func RegisterTools ¶
func RegisterTools(server *mcp.Server, client *gitlabclient.Client)
RegisterTools registers all commit-related MCP tools on the given server.
Types ¶
type Action ¶
type Action struct {
Action string `json:"action" jsonschema:"Action to perform on the file (create, update, delete, move),required"`
FilePath string `json:"file_path" jsonschema:"Full path of the file (e.g. src/main.go),required"`
Content string `json:"content,omitempty" jsonschema:"File content (required for create and update)"`
PreviousPath string `json:"previous_path,omitempty" jsonschema:"Original path when action is move"`
LastCommitID string `json:"last_commit_id,omitempty" jsonschema:"Last known commit ID of this file for conflict detection"`
}
Action specifies a single file operation within a commit.
type BasicMROutput ¶
type BasicMROutput struct {
ID int64 `json:"id"`
IID int64 `json:"mr_iid"`
Title string `json:"title"`
State string `json:"state"`
SourceBranch string `json:"source_branch"`
TargetBranch string `json:"target_branch"`
WebURL string `json:"web_url"`
Author string `json:"author,omitempty"`
}
BasicMROutput represents a basic merge request associated with a commit.
type CherryPickInput ¶
type CherryPickInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA to cherry-pick"`
Branch string `json:"branch" jsonschema:"Target branch name,required"`
DryRun bool `json:"dry_run,omitempty" jsonschema:"If true, does not create the commit but checks for conflicts"`
Message string `json:"message,omitempty" jsonschema:"Custom commit message (defaults to original)"`
}
CherryPickInput defines parameters for cherry-picking a commit.
type CommentOutput ¶
type CommentOutput struct {
toolutil.HintableOutput
Note string `json:"note"`
Path string `json:"path,omitempty"`
Line int64 `json:"line,omitempty"`
LineType string `json:"line_type,omitempty"`
Author string `json:"author"`
}
CommentOutput represents a single commit comment.
func PostComment ¶
func PostComment(ctx context.Context, client *gitlabclient.Client, input PostCommentInput) (CommentOutput, error)
PostComment creates a comment on a commit.
type CommentsInput ¶
type CommentsInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA,required"`
toolutil.PaginationInput
}
CommentsInput defines parameters for listing comments on a commit.
type CommentsOutput ¶
type CommentsOutput struct {
toolutil.HintableOutput
Comments []CommentOutput `json:"comments"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
CommentsOutput holds a paginated list of commit comments.
func GetComments ¶
func GetComments(ctx context.Context, client *gitlabclient.Client, input CommentsInput) (CommentsOutput, error)
GetComments retrieves the comments on a commit.
type CreateInput ¶
type CreateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Branch string `json:"branch" jsonschema:"Target branch name,required"`
CommitMessage string `json:"commit_message" jsonschema:"Commit message,required"`
Actions []Action `json:"actions" jsonschema:"List of file actions (create, update, delete, move),required"`
StartBranch string `json:"start_branch,omitempty" jsonschema:"Branch to start from if target branch does not exist"`
StartSHA string `json:"start_sha,omitempty" jsonschema:"SHA to start from if target branch does not exist (alternative to start_branch)"`
AuthorEmail string `json:"author_email,omitempty" jsonschema:"Custom author email"`
AuthorName string `json:"author_name,omitempty" jsonschema:"Custom author name"`
Force bool `json:"force,omitempty" jsonschema:"When true, force-overwrite the target branch even if a conflict exists"`
}
CreateInput defines parameters for creating a commit with file actions.
type DetailOutput ¶
type DetailOutput struct {
toolutil.HintableOutput
ID string `json:"id"`
ShortID string `json:"short_id"`
Title string `json:"title"`
Message string `json:"message"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
CommitterName string `json:"committer_name"`
CommitterEmail string `json:"committer_email"`
CommittedDate string `json:"committed_date"`
WebURL string `json:"web_url"`
ParentIDs []string `json:"parent_ids"`
Status string `json:"status,omitempty"`
Stats *StatsOutput `json:"stats,omitempty"`
}
DetailOutput represents a single commit with full details.
func Get ¶
func Get(ctx context.Context, client *gitlabclient.Client, input GetInput) (DetailOutput, error)
Get retrieves a single commit by SHA from a GitLab project.
type DiffInput ¶
type DiffInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA hash to get diffs for,required"`
Unidiff bool `json:"unidiff,omitempty" jsonschema:"Return diffs in unified diff format"`
toolutil.PaginationInput
}
DiffInput defines parameters for retrieving diffs of a commit.
type DiffOutput ¶
type DiffOutput struct {
toolutil.HintableOutput
Diffs []toolutil.DiffOutput `json:"diffs"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
DiffOutput holds the list of file diffs for a commit.
func Diff ¶
func Diff(ctx context.Context, client *gitlabclient.Client, input DiffInput) (DiffOutput, error)
Diff retrieves the file diffs for a specific commit.
type GPGSignatureInput ¶
type GPGSignatureInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA,required"`
}
GPGSignatureInput defines parameters for retrieving a commit's GPG signature.
type GPGSignatureOutput ¶
type GPGSignatureOutput struct {
toolutil.HintableOutput
KeyID int64 `json:"gpg_key_id"`
KeyPrimaryKeyID string `json:"gpg_key_primary_keyid"`
KeyUserName string `json:"gpg_key_user_name"`
KeyUserEmail string `json:"gpg_key_user_email"`
VerificationStatus string `json:"verification_status"`
KeySubkeyID int64 `json:"gpg_key_subkey_id,omitempty"`
}
GPGSignatureOutput represents a commit's GPG signature.
func GetGPGSignature ¶
func GetGPGSignature(ctx context.Context, client *gitlabclient.Client, input GPGSignatureInput) (GPGSignatureOutput, error)
GetGPGSignature retrieves the GPG signature of a commit.
type GetInput ¶
type GetInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA hash to retrieve,required"`
}
GetInput defines parameters for retrieving a single commit.
type ListInput ¶
type ListInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
RefName string `json:"ref_name,omitempty" jsonschema:"Branch name, tag, or commit SHA to list commits from (default: default branch)"`
Since string `json:"since,omitempty" jsonschema:"Return commits after this date (ISO 8601 format, e.g. 2025-01-01T00:00:00Z)"`
Until string `json:"until,omitempty" jsonschema:"Return commits before this date (ISO 8601 format, e.g. 2025-12-31T23:59:59Z)"`
Path string `json:"path,omitempty" jsonschema:"File path to filter commits by (only commits touching this path)"`
Author string `json:"author,omitempty" jsonschema:"Filter by commit author name or email"`
WithStats bool `json:"with_stats,omitempty" jsonschema:"Include commit stats (additions, deletions, total)"`
FirstParent bool `json:"first_parent,omitempty" jsonschema:"Follow only the first parent commit upon seeing a merge commit"`
toolutil.PaginationInput
}
ListInput defines parameters for listing commits in a GitLab project.
type ListOutput ¶
type ListOutput struct {
toolutil.HintableOutput
Commits []Output `json:"commits"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
ListOutput holds a paginated list of commits.
func List ¶
func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)
List retrieves a paginated list of commits for a GitLab project. Supports filtering by branch/tag, date range, file path, and author.
type MRsByCommitInput ¶
type MRsByCommitInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA,required"`
}
MRsByCommitInput defines parameters for listing merge requests associated with a commit.
type MRsByCommitOutput ¶
type MRsByCommitOutput struct {
toolutil.HintableOutput
MergeRequests []BasicMROutput `json:"merge_requests"`
}
MRsByCommitOutput holds the list of merge requests for a commit.
func ListMRsByCommit ¶
func ListMRsByCommit(ctx context.Context, client *gitlabclient.Client, input MRsByCommitInput) (MRsByCommitOutput, error)
ListMRsByCommit retrieves merge requests associated with a commit.
type Output ¶
type Output struct {
toolutil.HintableOutput
ID string `json:"id"`
ShortID string `json:"short_id"`
Title string `json:"title"`
Message string `json:"message,omitempty"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
AuthoredDate string `json:"authored_date,omitempty"`
CommitterName string `json:"committer_name"`
CommitterEmail string `json:"committer_email"`
CommittedDate string `json:"committed_date"`
CreatedAt string `json:"created_at,omitempty"`
WebURL string `json:"web_url"`
ParentIDs []string `json:"parent_ids,omitempty"`
Status string `json:"status,omitempty"`
ProjectID int64 `json:"project_id,omitempty"`
Stats *StatsOutput `json:"stats,omitempty"`
}
Output represents a created commit.
func CherryPick ¶
func CherryPick(ctx context.Context, client *gitlabclient.Client, input CherryPickInput) (Output, error)
CherryPick cherry-picks a commit to a target branch.
func Create ¶
func Create(ctx context.Context, client *gitlabclient.Client, input CreateInput) (Output, error)
Create creates a new commit in the specified GitLab project with one or more file actions. Supports optional start branch (to create a new branch from an existing one) and custom author metadata. Returns the created commit details or an error if the API call fails.
func Revert ¶
func Revert(ctx context.Context, client *gitlabclient.Client, input RevertInput) (Output, error)
Revert reverts a commit on a target branch.
type PostCommentInput ¶
type PostCommentInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA,required"`
Note string `json:"note" jsonschema:"Comment text,required"`
Path string `json:"path,omitempty" jsonschema:"File path to comment on (for inline comments)"`
Line int64 `json:"line,omitempty" jsonschema:"Line number to comment on"`
LineType string `json:"line_type,omitempty" jsonschema:"Line type: new or old (default: new)"`
}
PostCommentInput defines parameters for posting a comment on a commit.
type RefsInput ¶
type RefsInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA to look up,required"`
Type string `json:"type,omitempty" jsonschema:"Filter by ref type: branch, tag, or all (default: all)"`
toolutil.PaginationInput
}
RefsInput defines parameters for retrieving branches/tags referencing a commit.
type RefsOutput ¶
type RefsOutput struct {
toolutil.HintableOutput
Refs []RefOutput `json:"refs"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
RefsOutput holds a paginated list of refs referencing a commit.
func GetRefs ¶
func GetRefs(ctx context.Context, client *gitlabclient.Client, input RefsInput) (RefsOutput, error)
GetRefs retrieves branches and tags a commit is pushed to.
type RevertInput ¶
type RevertInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA to revert"`
Branch string `json:"branch" jsonschema:"Target branch name,required"`
}
RevertInput defines parameters for reverting a commit.
type SetStatusInput ¶
type SetStatusInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA,required"`
State string `json:"state" jsonschema:"Status state: pending, running, success, failed, canceled,required"`
Ref string `json:"ref,omitempty" jsonschema:"Branch or tag name"`
Name string `json:"name,omitempty" jsonschema:"Status name / context"`
Context string `json:"context,omitempty" jsonschema:"Status context label (overrides name)"`
TargetURL string `json:"target_url,omitempty" jsonschema:"URL to link from the status"`
Description string `json:"description,omitempty" jsonschema:"Short description of the status"`
Coverage float64 `json:"coverage,omitempty" jsonschema:"Code coverage percentage"`
PipelineID int64 `json:"pipeline_id,omitempty" jsonschema:"Pipeline ID to associate the status with"`
}
SetStatusInput defines parameters for setting a commit pipeline status.
type StatsOutput ¶
type StatsOutput struct {
Additions int64 `json:"additions"`
Deletions int64 `json:"deletions"`
Total int64 `json:"total"`
}
StatsOutput holds additions/deletions/total for a commit.
type StatusOutput ¶
type StatusOutput struct {
toolutil.HintableOutput
ID int64 `json:"id"`
SHA string `json:"sha"`
Ref string `json:"ref"`
Status string `json:"status"`
Name string `json:"name"`
TargetURL string `json:"target_url,omitempty"`
Description string `json:"description,omitempty"`
Coverage float64 `json:"coverage,omitempty"`
PipelineID int64 `json:"pipeline_id,omitempty"`
AllowFailure bool `json:"allow_failure,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
StartedAt string `json:"started_at,omitempty"`
FinishedAt string `json:"finished_at,omitempty"`
Author string `json:"author,omitempty"`
}
StatusOutput represents a single commit pipeline status.
func SetStatus ¶
func SetStatus(ctx context.Context, client *gitlabclient.Client, input SetStatusInput) (StatusOutput, error)
SetStatus sets the pipeline status of a commit.
type StatusesInput ¶
type StatusesInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
SHA string `json:"sha" jsonschema:"Commit SHA,required"`
Ref string `json:"ref,omitempty" jsonschema:"Branch or tag name filter"`
Stage string `json:"stage,omitempty" jsonschema:"Stage name filter"`
Name string `json:"name,omitempty" jsonschema:"Status name filter"`
PipelineID int64 `json:"pipeline_id,omitempty" jsonschema:"Pipeline ID filter"`
All bool `json:"all,omitempty" jsonschema:"Return all statuses including retries"`
toolutil.PaginationInput
}
StatusesInput defines parameters for listing pipeline statuses of a commit.
type StatusesOutput ¶
type StatusesOutput struct {
toolutil.HintableOutput
Statuses []StatusOutput `json:"statuses"`
Pagination toolutil.PaginationOutput `json:"pagination"`
}
StatusesOutput holds a paginated list of commit statuses.
func GetStatuses ¶
func GetStatuses(ctx context.Context, client *gitlabclient.Client, input StatusesInput) (StatusesOutput, error)
GetStatuses retrieves the pipeline statuses of a commit.