Documentation
¶
Overview ¶
Package repositorysubmodules implements MCP tools for GitLab repository submodule operations.
The package wraps the GitLab Repository submodules API:
Index ¶
- func ActionSpecs(client *gitlabclient.Client) []toolutil.ActionSpec
- func FormatListMarkdown(out ListOutput) *mcp.CallToolResult
- func FormatReadMarkdown(out ReadOutput) *mcp.CallToolResult
- func FormatUpdateMarkdown(out UpdateOutput) *mcp.CallToolResult
- type ListInput
- type ListOutput
- type ReadInput
- type ReadOutput
- type SubmoduleEntry
- type UpdateInput
- type UpdateOutput
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 repository submodule actions. Each action carries non-generic discovery metadata (1:1 audit R-META): action-specific Usage, submodule-phrased natural-language Aliases, canonical repository.*/commit.* RelatedActions, and an individual-tool Description in "Returns: … See also: …" form.
func FormatListMarkdown ¶
func FormatListMarkdown(out ListOutput) *mcp.CallToolResult
FormatListMarkdown renders the submodules of a repository as a Markdown table.
func FormatReadMarkdown ¶
func FormatReadMarkdown(out ReadOutput) *mcp.CallToolResult
FormatReadMarkdown renders a file read out of a submodule as the card of the file, with the body fenced under a section of its own.
func FormatUpdateMarkdown ¶
func FormatUpdateMarkdown(out UpdateOutput) *mcp.CallToolResult
FormatUpdateMarkdown renders the commit a submodule update created as the card of that commit.
Types ¶
type ListInput ¶
type ListInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Ref string `json:"ref,omitempty" jsonschema:"Branch name, tag, or commit SHA (defaults to default branch)"`
}
ListInput defines parameters for listing submodules in a repository.
type ListOutput ¶
type ListOutput struct {
toolutil.HintableOutput
Submodules []SubmoduleEntry `json:"submodules"`
Count int `json:"count"`
}
ListOutput holds the list of submodules found in the repository.
func List ¶
func List(ctx context.Context, client *gitlabclient.Client, input ListInput) (ListOutput, error)
List retrieves all submodules defined in a repository by parsing .gitmodules and correlating each entry with its commit SHA from the repository tree.
type ReadInput ¶
type ReadInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path of the parent repository,required"`
SubmodulePath string `json:"submodule_path" jsonschema:"Path to the submodule as defined in .gitmodules (e.g. libs/core-module),required"`
FilePath string `json:"file_path" jsonschema:"Path of the file inside the submodule (e.g. src/main.c),required"`
Ref string `json:"ref,omitempty" jsonschema:"Branch/tag/SHA in the parent repository (defaults to default branch)"`
}
ReadInput defines parameters for reading a file inside a submodule.
type ReadOutput ¶
type ReadOutput struct {
toolutil.HintableOutput
FileName string `json:"file_name"`
FilePath string `json:"file_path"`
SubmodulePath string `json:"submodule_path"`
ResolvedProject string `json:"resolved_project"`
CommitSHA string `json:"commit_sha"`
Size int64 `json:"size"`
Content string `json:"content"`
Encoding string `json:"encoding"`
}
ReadOutput holds the file content retrieved from inside a submodule.
func Read ¶
func Read(ctx context.Context, client *gitlabclient.Client, input ReadInput) (ReadOutput, error)
Read resolves a submodule in the parent repository and retrieves a file from the submodule's target project at the pinned commit SHA.
Steps:
- Get .gitmodules from parent, and the parent project itself, to resolve the submodule URL to the project on this instance it names ([submoduleResolver]); a submodule naming none is refused here
- Get tree entry for the submodule path to obtain the pinned commit SHA
- Fetch the file from the resolved project at that commit SHA
type SubmoduleEntry ¶
type SubmoduleEntry struct {
Name string `json:"name"`
Path string `json:"path"`
URL string `json:"url"`
ResolvedProject string `json:"resolved_project,omitempty"`
External bool `json:"external,omitempty"`
Unresolved bool `json:"unresolved,omitempty"`
CommitSHA string `json:"commit_sha"`
// contains filtered or unexported fields
}
SubmoduleEntry represents a single submodule with its configuration and current commit pointer. URL is the remote as .gitmodules writes it with any credentials removed ([redactRemote]); ResolvedProject is the project on this instance it names ([submoduleResolver]), and carries no credentials either. A submodule naming no project here is marked one of two ways, and cannot be read through this server: External when its remote names another host, where it can be read instead, and Unresolved otherwise, a relative URL that lands inside the superproject or at the root, a remote on this instance's host that is not a project's clone URL, or one that names no host at all.
type UpdateInput ¶
type UpdateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Submodule string `json:"submodule" jsonschema:"Full path of the submodule in the repository, as .gitmodules writes it (e.g. libs/dep),required"`
Branch string `json:"branch" jsonschema:"Branch name to commit the update to,required"`
CommitSHA string `json:"commit_sha" jsonschema:"Full commit SHA to update the submodule to,required"`
CommitMessage string `json:"commit_message,omitempty" jsonschema:"Custom commit message (optional)"`
}
UpdateInput is the input for updating a submodule reference.
type UpdateOutput ¶
type UpdateOutput struct {
toolutil.HintableOutput
ID string `json:"id"`
ShortID string `json:"short_id"`
Title string `json:"title"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
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"`
ParentIDs []string `json:"parent_ids,omitempty"`
Status string `json:"status,omitempty"`
ProjectID int64 `json:"project_id,omitempty"`
WebURL string `json:"web_url,omitempty"`
Trailers map[string]string `json:"trailers,omitempty"`
ExtendedTrailers map[string][]string `json:"extended_trailers,omitempty"`
LastPipeline *toolutil.LastPipelineOutput `json:"last_pipeline,omitempty"`
}
UpdateOutput is the commit a submodule update created, which the route renders through lib/api/entities/commit_detail.rb: identity, author and committer attribution, the three instants, parents, message, build status, the project, the web URL, the trailers and the commit's latest pipeline.
client-go decodes the answer into a SubmoduleCommit, which models the first thirteen of those and none of the last five, so those are read off the captured response ([submoduleCommitExtra]). extended_trailers is typed as GitLab sends it, each key to the list of its values: client-go's Commit declares it a map of strings, which cannot hold a trailer GitLab has parsed.
func Update ¶
func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (UpdateOutput, error)
Update updates a submodule reference in a repository.