update-pull-request-branch
Update a pull request branch with the latest changes from the base branch to resolve merge conflicts and ensure code is current.
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
- src/tools/pull-requests.ts:342-359 (handler)The core handler function implementing the 'update-pull-request-branch' tool. It validates input using Zod schema, calls the GitHub API's pulls.updateBranch method, and returns the result.export async function updatePullRequestBranch(args: unknown): Promise<any> { const { owner, repo, pull_number, expected_head_sha } = UpdatePullRequestBranchSchema.parse(args); const github = getGitHubApi(); return tryCatchAsync(async () => { const { data } = await github.getOctokit().pulls.updateBranch({ owner, repo, pull_number, expected_head_sha, }); return { message: data.message, url: data.url, }; }, 'Failed to update pull request branch'); }
- src/utils/validation.ts:169-172 (schema)Zod schema for validating the input parameters of the update-pull-request-branch tool.export const UpdatePullRequestBranchSchema = OwnerRepoSchema.extend({ pull_number: z.number().int().positive(), expected_head_sha: z.string().optional(), });
- src/server.ts:950-976 (registration)Tool registration in the ListTools response, defining the tool name, description, and input schema.{ name: 'update-pull-request-branch', description: 'Update a pull request branch with the latest changes from the base branch', inputSchema: { type: 'object', properties: { owner: { type: 'string', description: 'Repository owner (username or organization)', }, repo: { type: 'string', description: 'Repository name', }, pull_number: { type: 'number', description: 'Pull request number', }, expected_head_sha: { type: 'string', description: 'The expected SHA of the pull request\'s HEAD ref', }, }, required: ['owner', 'repo', 'pull_number'], additionalProperties: false, }, },
- src/server.ts:1244-1246 (registration)Dispatch case in the CallToolRequest handler that invokes the updatePullRequestBranch function.case 'update-pull-request-branch': result = await updatePullRequestBranch(parsedArgs); break;