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.
func FormatListMarkdown ¶
func FormatListMarkdown(out ListOutput) *mcp.CallToolResult
FormatListMarkdown renders the submodule list as a Markdown table.
func FormatReadMarkdown ¶
func FormatReadMarkdown(out ReadOutput) *mcp.CallToolResult
FormatReadMarkdown renders the submodule file read result as Markdown.
func FormatUpdateMarkdown ¶
func FormatUpdateMarkdown(out UpdateOutput) *mcp.CallToolResult
FormatUpdateMarkdown formats the submodule update result as markdown.
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 to resolve submodule URL → project path
- 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"`
CommitSHA string `json:"commit_sha"`
}
SubmoduleEntry represents a single submodule with its configuration and current commit pointer.
type UpdateInput ¶
type UpdateInput struct {
ProjectID toolutil.StringOrInt `json:"project_id" jsonschema:"Project ID or URL-encoded path,required"`
Submodule string `json:"submodule" jsonschema:"URL-encoded full path to the submodule,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"`
Message string `json:"message"`
CreatedAt string `json:"created_at,omitempty"`
CommittedDate string `json:"committed_date,omitempty"`
}
UpdateOutput is the output for a submodule update.
func Update ¶
func Update(ctx context.Context, client *gitlabclient.Client, input UpdateInput) (UpdateOutput, error)
Update updates a submodule reference in a repository.