Determinstically set up PR branch

This commit is contained in:
Colin McDonnell
2025-12-15 21:12:55 -08:00
parent 1d69f0f3e4
commit a19ae49224
6 changed files with 54 additions and 95 deletions
+18 -5
View File
@@ -39511,7 +39511,7 @@ async function reportProgress({ body }) {
}
const issueNumber = ctx.payload.event.issue_number;
if (issueNumber === void 0) {
throw new Error("cannot create progress comment: no issue_number found in the payload event");
return void 0;
}
const result = await ctx.octokit.rest.issues.createComment({
owner: ctx.owner,
@@ -39679,6 +39679,12 @@ var init_comment = __esm({
parameters: ReportProgress,
execute: contextualize(async ({ body }) => {
const result = await reportProgress({ body });
if (!result) {
return {
success: false,
message: "cannot create progress comment: no issue_number found in the payload event. this may occur for workflow_dispatch events or when there is no associated issue/PR. if you need to comment on a specific issue or PR, use create_issue_comment with an explicit issueNumber."
};
}
return {
success: true,
...result
@@ -124233,7 +124239,8 @@ function $(cmd, args3, options) {
const result = spawnSync4(cmd, args3, {
stdio: ["ignore", "pipe", "pipe"],
encoding,
cwd: options?.cwd
cwd: options?.cwd,
env: options?.env ? { ...process.env, ...options.env } : void 0
});
const stdout = result.stdout ?? "";
const stderr = result.stderr ?? "";
@@ -124719,6 +124726,7 @@ var PullRequestTool = tool({
// mcp/prInfo.ts
init_out4();
init_cli();
init_github();
init_shared3();
var PullRequestInfo = type({
pull_number: type.number.describe("The pull request number to fetch")
@@ -124743,7 +124751,10 @@ var PullRequestInfoTool = tool({
const headRepo = data.head.repo.full_name;
const isFork = headRepo !== baseRepo;
log.info(`Checking out PR #${pull_number} using gh pr checkout`);
$("gh", ["pr", "checkout", pull_number.toString()]);
const token = getGitHubInstallationToken();
$("gh", ["pr", "checkout", pull_number.toString()], {
env: { GH_TOKEN: token }
});
log.info(`Fetching base branch: origin/${baseBranch}`);
$("git", ["fetch", "origin", baseBranch, "--depth=20"]);
const currentBranch = $("git", ["rev-parse", "--abbrev-ref", "HEAD"], { log: false }).trim();
@@ -125103,6 +125114,7 @@ init_github();
// utils/setup.ts
import { execSync } from "node:child_process";
init_cli();
init_github();
function setupGitConfig() {
const repoDir = process.cwd();
log.info("\u{1F527} Setting up git configuration...");
@@ -125150,9 +125162,10 @@ function setupGitBranch(payload) {
const prNumber = payload.event.issue_number;
try {
log.debug(`Checking out PR #${prNumber} using gh pr checkout`);
execSync(`gh pr checkout ${prNumber}`, {
const token = getGitHubInstallationToken();
$("gh", ["pr", "checkout", prNumber.toString()], {
cwd: repoDir,
stdio: "pipe"
env: { GH_TOKEN: token }
});
log.info(`\u2713 Successfully checked out PR branch: ${branch}`);
return;