@tiberriver256/mcp-server-azure-devops
Version:
Azure DevOps reference server for the Model Context Protocol (MCP)
56 lines • 2.09 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPullRequest = createPullRequest;
const errors_1 = require("../../../shared/errors");
/**
* Create a pull request
*
* @param connection The Azure DevOps WebApi connection
* @param projectId The ID or name of the project
* @param repositoryId The ID or name of the repository
* @param options Options for creating the pull request
* @returns The created pull request
*/
async function createPullRequest(connection, projectId, repositoryId, options) {
try {
if (!options.title) {
throw new Error('Title is required');
}
if (!options.sourceRefName) {
throw new Error('Source branch is required');
}
if (!options.targetRefName) {
throw new Error('Target branch is required');
}
const gitApi = await connection.getGitApi();
// Create the pull request object
const pullRequest = {
title: options.title,
description: options.description,
sourceRefName: options.sourceRefName,
targetRefName: options.targetRefName,
isDraft: options.isDraft || false,
workItemRefs: options.workItemRefs?.map((id) => ({
id: id.toString(),
})),
reviewers: options.reviewers?.map((reviewer) => ({
id: reviewer,
isRequired: true,
})),
...options.additionalProperties,
};
// Create the pull request
const createdPullRequest = await gitApi.createPullRequest(pullRequest, repositoryId, projectId);
if (!createdPullRequest) {
throw new Error('Failed to create pull request');
}
return createdPullRequest;
}
catch (error) {
if (error instanceof errors_1.AzureDevOpsError) {
throw error;
}
throw new Error(`Failed to create pull request: ${error instanceof Error ? error.message : String(error)}`);
}
}
//# sourceMappingURL=feature.js.map