@therealchristhomas/gitlab-mcp-server
Version:
MCP Server for GitLab API operations
20 lines (19 loc) • 707 B
JavaScript
import { gitlabPost, encodeProjectId } from "../utils/gitlab-client.js";
import { GitLabReferenceSchema } from "../types/index.js";
export async function createBranch(projectId, options) {
if (!projectId?.trim()) {
throw new Error("Project ID is required");
}
if (!options.name?.trim()) {
throw new Error("Branch name is required");
}
if (!options.ref?.trim()) {
throw new Error("Source reference is required");
}
const endpoint = `/projects/${encodeProjectId(projectId)}/repository/branches`;
const branch = await gitlabPost(endpoint, {
branch: options.name,
ref: options.ref
});
return GitLabReferenceSchema.parse(branch);
}