UNPKG

@mcp-apps/azure-devops-mcp-server

Version:

A Model Context Protocol (MCP) server for Azure DevOps integration

97 lines (95 loc) 4.32 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.createBranchTool = void 0; const zod_1 = require("zod"); const child_process = __importStar(require("child_process")); const util = __importStar(require("util")); const execPromise = util.promisify(child_process.exec); // Tool to create a new branch exports.createBranchTool = { name: "git-create-branch", description: ` Creates a new branch in a Git repository. This tool creates a new branch in the specified local Git repository, optionally based on another branch or commit. Parameters: - repositoryPath: The local path to the Git repository Example: "C:\\projects\\my-repo" or "/home/user/projects/my-repo" - branchName: The name of the new branch to create Example: "feature/login", "bugfix/issue-123" - startPoint: Optional branch name or commit hash to start the new branch from Example: "main", "develop", "a1b2c3d4" (default: current HEAD) - checkout: Whether to check out the new branch after creating it (default: true) `, parameters: { repositoryPath: zod_1.z.string().describe("Local path to the Git repository"), branchName: zod_1.z.string().describe("Name of the new branch to create"), startPoint: zod_1.z.string().optional().describe("Branch name or commit hash to start from (default: current HEAD)"), checkout: zod_1.z.boolean().default(true).describe("Whether to check out the new branch after creating it"), }, handler: async ({ repositoryPath, branchName, startPoint, checkout }) => { try { // Build the branch creation command let command = checkout ? "checkout -b" : "branch"; command = `${command} "${branchName}"`; if (startPoint) { command += ` "${startPoint}"`; } // Execute the command const { stdout, stderr } = await execPromise(`git ${command}`, { cwd: repositoryPath }); if (stderr && stderr.trim() !== '') { return { content: [{ type: "text", text: `Warning during branch creation: ${stderr}` }], }; } return { content: [{ type: "text", text: `Branch "${branchName}" created successfully${checkout ? ' and checked out' : ''}. ${stdout ? `\nOutput: ${stdout}` : ''}` }], }; } catch (error) { console.error("Error creating branch:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error creating branch: ${errorMessage}` }], }; } } }; //# sourceMappingURL=git-create-branch.js.map