This commit is contained in:
Colin McDonnell
2025-12-15 21:21:57 -08:00
parent a19ae49224
commit 316b6cb83c
2 changed files with 18 additions and 71 deletions
+17 -70
View File
@@ -97449,7 +97449,7 @@ function query({
// package.json // package.json
var package_default = { var package_default = {
name: "@pullfrog/action", name: "@pullfrog/action",
version: "0.0.137", version: "0.0.138",
type: "module", type: "module",
files: [ files: [
"index.js", "index.js",
@@ -124725,15 +124725,13 @@ var PullRequestTool = tool({
// mcp/prInfo.ts // mcp/prInfo.ts
init_out4(); init_out4();
init_cli();
init_github();
init_shared3(); init_shared3();
var PullRequestInfo = type({ var PullRequestInfo = type({
pull_number: type.number.describe("The pull request number to fetch") pull_number: type.number.describe("The pull request number to fetch")
}); });
var PullRequestInfoTool = tool({ var PullRequestInfoTool = tool({
name: "get_pull_request", name: "get_pull_request",
description: "Retrieve PR information. Automatically fetches and checks out the PR branch.", description: "Retrieve PR information (metadata only). PR branch is already checked out during setup.",
parameters: PullRequestInfo, parameters: PullRequestInfo,
execute: contextualize(async ({ pull_number }, ctx) => { execute: contextualize(async ({ pull_number }, ctx) => {
const pr = await ctx.octokit.rest.pulls.get({ const pr = await ctx.octokit.rest.pulls.get({
@@ -124742,29 +124740,7 @@ var PullRequestInfoTool = tool({
pull_number pull_number
}); });
const data = pr.data; const data = pr.data;
const baseBranch = data.base.ref; const isFork = data.head.repo.full_name !== data.base.repo.full_name;
const headBranch = data.head.ref;
if (!baseBranch) {
throw new Error(`Base branch not found for PR #${pull_number}`);
}
const baseRepo = data.base.repo.full_name;
const headRepo = data.head.repo.full_name;
const isFork = headRepo !== baseRepo;
log.info(`Checking out PR #${pull_number} using gh pr checkout`);
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();
const currentSha = $("git", ["rev-parse", "HEAD"], { log: false }).trim();
const baseSha = $("git", ["rev-parse", `origin/${baseBranch}`], { log: false }).trim();
const summary2 = `PR branch has been fetched and checked out:
- Base branch: \`origin/${baseBranch}\` (${baseSha.substring(0, 7)})
- PR branch: \`${headBranch}\` (checked out locally, ${currentSha.substring(0, 7)})
- Current branch: \`${currentBranch}\`
- View diff: \`git diff origin/${baseBranch}...HEAD\``;
return { return {
number: data.number, number: data.number,
url: data.html_url, url: data.html_url,
@@ -124772,10 +124748,9 @@ var PullRequestInfoTool = tool({
state: data.state, state: data.state,
draft: data.draft, draft: data.draft,
merged: data.merged, merged: data.merged,
base: baseBranch, base: data.base.ref,
head: headBranch, head: data.head.ref,
isFork, isFork
summary: summary2
}; };
}) })
}); });
@@ -125151,47 +125126,19 @@ function setupGitAuth(ctx) {
log.info("\u2713 Updated remote URL with authentication token (scoped to repo)"); log.info("\u2713 Updated remote URL with authentication token (scoped to repo)");
} }
function setupGitBranch(payload) { function setupGitBranch(payload) {
const branch = payload.event.branch; if (payload.event.is_pr !== true || !payload.event.issue_number) {
const repoDir = process.cwd(); log.debug("Not a PR event, staying on default branch");
if (!branch) {
log.debug("No branch specified in payload, using default branch");
return; return;
} }
log.info(`\u{1F33F} Setting up git branch: ${branch}`); const prNumber = payload.event.issue_number;
if (payload.event.is_pr === true && payload.event.issue_number) { const repoDir = process.cwd();
const prNumber = payload.event.issue_number; log.info(`\u{1F33F} Checking out PR #${prNumber}...`);
try { const token = getGitHubInstallationToken();
log.debug(`Checking out PR #${prNumber} using gh pr checkout`); $("gh", ["pr", "checkout", prNumber.toString()], {
const token = getGitHubInstallationToken(); cwd: repoDir,
$("gh", ["pr", "checkout", prNumber.toString()], { env: { GH_TOKEN: token }
cwd: repoDir, });
env: { GH_TOKEN: token } log.info(`\u2713 Successfully checked out PR #${prNumber}`);
});
log.info(`\u2713 Successfully checked out PR branch: ${branch}`);
return;
} catch (error41) {
log.debug(
`gh pr checkout failed, falling back to branch name fetch: ${error41 instanceof Error ? error41.message : String(error41)}`
);
}
}
try {
log.debug(`Fetching branch from origin: ${branch}`);
execSync(`git fetch origin ${branch}`, {
cwd: repoDir,
stdio: "pipe"
});
log.debug(`Checking out branch: ${branch}`);
execSync(`git checkout -B ${branch} origin/${branch}`, {
cwd: repoDir,
stdio: "pipe"
});
log.info(`\u2713 Successfully checked out branch: ${branch}`);
} catch (error41) {
log.warning(
`Failed to checkout branch ${branch}: ${error41 instanceof Error ? error41.message : String(error41)}`
);
}
} }
// utils/timer.ts // utils/timer.ts
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@pullfrog/action", "name": "@pullfrog/action",
"version": "0.0.137", "version": "0.0.138",
"type": "module", "type": "module",
"files": [ "files": [
"index.js", "index.js",