fix: Add missing CreatePullRequestSchema and createPullRequest function

This commit is contained in:
Justin Spahr-Summers
2025-01-14 11:19:13 +00:00
parent a12c6ff23d
commit de256a48b1

View File

@@ -76,6 +76,17 @@ export const PullRequestReviewSchema = z.object({
});
// Input schemas
export const CreatePullRequestSchema = z.object({
owner: z.string().describe("Repository owner (username or organization)"),
repo: z.string().describe("Repository name"),
title: z.string().describe("Pull request title"),
body: z.string().optional().describe("Pull request body/description"),
head: z.string().describe("The name of the branch where your changes are implemented"),
base: z.string().describe("The name of the branch you want the changes pulled into"),
draft: z.boolean().optional().describe("Whether to create the pull request as a draft"),
maintainer_can_modify: z.boolean().optional().describe("Whether maintainers can modify the pull request")
});
export const GetPullRequestSchema = z.object({
owner: z.string().describe("Repository owner (username or organization)"),
repo: z.string().describe("Repository name"),
@@ -149,6 +160,22 @@ export const GetPullRequestReviewsSchema = z.object({
});
// Function implementations
export async function createPullRequest(
params: z.infer<typeof CreatePullRequestSchema>
): Promise<z.infer<typeof GitHubPullRequestSchema>> {
const { owner, repo, ...options } = CreatePullRequestSchema.parse(params);
const response = await githubRequest(
`https://api.github.com/repos/${owner}/${repo}/pulls`,
{
method: "POST",
body: options,
}
);
return GitHubPullRequestSchema.parse(response);
}
export async function getPullRequest(
owner: string,
repo: string,