complete_git_workflow
Automate Git workflows by committing changes, pushing code, creating pull requests, and optionally merging. Supports conventional commits, dry runs, and handles branch management for streamlined development processes.
Instructions
Execute complete Git workflow: commit, push, create PR, and optionally merge
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| autoMerge | No | Automatically merge PR after creation | |
| baseBranch | No | Base branch | main |
| branch | No | Feature branch name | |
| commitMessage | Yes | Commit message (conventional format) | |
| dryRun | No | Preview without executing | |
| files | No | Files to commit | |
| prBody | Yes | Pull request description | |
| prTitle | Yes | Pull request title | |
| workingDir | No | Working directory path |
Implementation Reference
- src/index.ts:345-411 (handler)The primary handler function that implements the complete_git_workflow tool logic. It coordinates committing and pushing changes, creating a pull request, and optionally auto-merging.async function completeGitWorkflow( files: string[], commitMessage: string, prTitle: string, prBody: string, branch?: string, baseBranch: string = 'main', autoMerge: boolean = false, workingDir?: string, dryRun: boolean = false ): Promise<WorkflowResult> { try { if (dryRun) { return { success: true, message: "Dry run: Would execute complete Git workflow", details: { files, commitMessage, prTitle, prBody, branch, baseBranch, autoMerge } }; } // Step 1: Commit and push const commitResult = await commitAndPush(files, commitMessage, branch, workingDir); if (!commitResult.success) { return commitResult; } // Step 2: Create pull request const prResult = await createPullRequest(prTitle, prBody, baseBranch, branch, workingDir); if (!prResult.success) { return prResult; } let mergeResult = null; if (autoMerge && prResult.details?.url) { // Extract PR number from URL const prMatch = prResult.details.url.match(/\/pull\/(\d+)$/); if (prMatch) { const prNumber = prMatch[1]; mergeResult = await mergePullRequest(prNumber, 'merge', true, workingDir); } } return { success: true, message: "Successfully completed Git workflow", details: { commit: commitResult.details, pullRequest: prResult.details, merge: mergeResult?.details } }; } catch (error: any) { return { success: false, message: "Git workflow failed", error: `Git workflow failed: ${error.message}` }; } }
- src/index.ts:524-568 (schema)JSON schema defining the input parameters and validation for the complete_git_workflow tool.inputSchema: { type: "object", properties: { files: { type: "array", items: { type: "string" }, description: "Files to commit" }, commitMessage: { type: "string", description: "Commit message (conventional format)" }, prTitle: { type: "string", description: "Pull request title" }, prBody: { type: "string", description: "Pull request description" }, branch: { type: "string", description: "Feature branch name" }, baseBranch: { type: "string", description: "Base branch", default: "main" }, autoMerge: { type: "boolean", description: "Automatically merge PR after creation", default: false }, workingDir: { type: "string", description: "Working directory path" }, dryRun: { type: "boolean", description: "Preview without executing", default: false } }, required: ["commitMessage", "prTitle", "prBody"]
- src/index.ts:521-570 (registration)Tool registration in the ListToolsRequestSchema handler, where the tool name, description, and schema are declared.{ name: "complete_git_workflow", description: "Execute complete Git workflow: commit, push, create PR, and optionally merge", inputSchema: { type: "object", properties: { files: { type: "array", items: { type: "string" }, description: "Files to commit" }, commitMessage: { type: "string", description: "Commit message (conventional format)" }, prTitle: { type: "string", description: "Pull request title" }, prBody: { type: "string", description: "Pull request description" }, branch: { type: "string", description: "Feature branch name" }, baseBranch: { type: "string", description: "Base branch", default: "main" }, autoMerge: { type: "boolean", description: "Automatically merge PR after creation", default: false }, workingDir: { type: "string", description: "Working directory path" }, dryRun: { type: "boolean", description: "Preview without executing", default: false } }, required: ["commitMessage", "prTitle", "prBody"] } }
- src/index.ts:616-628 (registration)Dispatch/registration in the CallToolRequestSchema switch statement that routes calls to the completeGitWorkflow handler.case "complete_git_workflow": result = await completeGitWorkflow( (args?.files as string[]) || [], args?.commitMessage as string, args?.prTitle as string, args?.prBody as string, args?.branch as string, (args?.baseBranch as string) || 'main', (args?.autoMerge as boolean) || false, args?.workingDir as string, (args?.dryRun as boolean) || false ); break;