complete_git_workflow
Automate Git workflows by committing files, pushing changes, creating pull requests, and merging with GitHub authentication handling.
Instructions
Execute complete Git workflow: commit, push, create PR, and optionally merge
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| files | No | Files to commit | |
| commitMessage | Yes | Commit message (conventional format) | |
| prTitle | Yes | Pull request title | |
| prBody | Yes | Pull request description | |
| branch | No | Feature branch name | |
| baseBranch | No | Base branch | main |
| autoMerge | No | Automatically merge PR after creation | |
| workingDir | No | Working directory path | |
| dryRun | No | Preview without executing |
Implementation Reference
- src/index.ts:345-411 (handler)The primary handler function that implements the complete_git_workflow tool logic, orchestrating commit/push, PR creation, and optional auto-merge.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-569 (schema)Input schema for the complete_git_workflow tool, defining parameters and validation rules.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, including name, description, and schema.{ 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 of the complete_git_workflow handler in the CallToolRequestSchema switch statement.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;