push_files
Push multiple files to a GitLab project in a single commit, enabling batch file updates with specified paths, content, and commit message.
Instructions
Push multiple files to a GitLab project in a single commit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID or URL-encoded path | |
| branch | Yes | Branch to push to | |
| files | Yes | Array of files to push | |
| commit_message | Yes | Commit message |
Implementation Reference
- src/server.ts:274-283 (handler)The request handler for "push_files" in src/server.ts. It parses the request arguments and calls the API function "createCommit".
case "push_files": { const args = PushFilesSchema.parse(request.params.arguments); const result = await api.createCommit( args.project_id, args.commit_message, args.branch, args.files.map((f) => ({ path: f.file_path, content: f.content })) ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } - src/api/files.ts:79-111 (handler)The implementation of the API function `createCommit` that actually interacts with GitLab to push the files.
export async function createCommit( projectId: string, message: string, branch: string, actions: FileOperation[] ): Promise<GitLabCommit> { if (!projectId?.trim()) { throw new Error("Project ID is required"); } if (!message?.trim()) { throw new Error("Commit message is required"); } if (!branch?.trim()) { throw new Error("Branch is required"); } if (!actions || actions.length === 0) { throw new Error("At least one file action is required"); } const endpoint = `/projects/${encodeProjectId(projectId)}/repository/commits`; const commit = await gitlabPost<GitLabCommit>(endpoint, { branch, commit_message: message, actions: actions.map((action) => ({ action: "create", file_path: action.path, content: action.content })) }); return GitLabCommitSchema.parse(commit); }