update_pull_request_branch
Synchronize a pull request branch with the latest changes from its base branch to resolve conflicts and maintain up-to-date code.
Instructions
Update a pull request branch with the latest changes from the base branch
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expected_head_sha | No | The expected SHA of the pull request's HEAD ref | |
| owner | Yes | Repository owner (username or organization) | |
| pull_number | Yes | Pull request number | |
| repo | Yes | Repository name |
Implementation Reference
- operations/pulls.ts:251-264 (handler)The core handler function that executes the GitHub API request to update the pull request branch with the latest changes.export async function updatePullRequestBranch( owner: string, repo: string, pullNumber: number, expectedHeadSha?: string ): Promise<void> { await githubRequest( `https://api.github.com/repos/${owner}/${repo}/pulls/${pullNumber}/update-branch`, { method: "PUT", body: expectedHeadSha ? { expected_head_sha: expectedHeadSha } : undefined, } ); }
- operations/pulls.ts:143-148 (schema)Zod input schema defining parameters for the tool: owner, repo, pull_number, and optional expected_head_sha.export const UpdatePullRequestBranchSchema = z.object({ owner: z.string().describe("Repository owner (username or organization)"), repo: z.string().describe("Repository name"), pull_number: z.number().describe("Pull request number"), expected_head_sha: z.string().optional().describe("The expected SHA of the pull request's HEAD ref") });
- index.ts:185-189 (registration)Tool registration in the listTools response, including name, description, and input schema reference.{ name: "update_pull_request_branch", description: "Update a pull request branch with the latest changes from the base branch", inputSchema: zodToJsonSchema(pulls.UpdatePullRequestBranchSchema) },
- index.ts:549-556 (handler)Dispatcher case in the central CallToolRequest handler that parses args and invokes the specific updatePullRequestBranch function.case "update_pull_request_branch": { const args = pulls.UpdatePullRequestBranchSchema.parse(request.params.arguments); const { owner, repo, pull_number, expected_head_sha } = args; await pulls.updatePullRequestBranch(owner, repo, pull_number, expected_head_sha); return { content: [{ type: "text", text: JSON.stringify({ success: true }, null, 2) }], }; }