fix(DNRY): Moving isGitHubActions to the module context (expensive operation), and the condition to updateSummary().
This commit is contained in:
@@ -106431,6 +106431,7 @@ var addTools = (ctx, server, tools) => {
|
|||||||
|
|
||||||
// mcp/comment.ts
|
// mcp/comment.ts
|
||||||
var LEAPING_INTO_ACTION_PREFIX = "Leaping into action";
|
var LEAPING_INTO_ACTION_PREFIX = "Leaping into action";
|
||||||
|
var isGitHubActions2 = !!process.env.GITHUB_ACTIONS;
|
||||||
async function buildCommentFooter({
|
async function buildCommentFooter({
|
||||||
payload,
|
payload,
|
||||||
octokit,
|
octokit,
|
||||||
@@ -106559,12 +106560,11 @@ function setProgressCommentId(id) {
|
|||||||
var ReportProgress = type({
|
var ReportProgress = type({
|
||||||
body: type.string.describe("the progress update content to share")
|
body: type.string.describe("the progress update content to share")
|
||||||
});
|
});
|
||||||
var updateSummary = (text) => core3.summary.addRaw(text).write({ overwrite: true });
|
var updateSummary = (text) => isGitHubActions2 && core3.summary.addRaw(text).write({ overwrite: true });
|
||||||
async function reportProgress(ctx, { body }) {
|
async function reportProgress(ctx, { body }) {
|
||||||
const existingCommentId = getProgressCommentId();
|
const existingCommentId = getProgressCommentId();
|
||||||
const issueNumber = ctx.toolState.prNumber ?? ctx.toolState.issueNumber ?? ctx.payload.event.issue_number;
|
const issueNumber = ctx.toolState.prNumber ?? ctx.toolState.issueNumber ?? ctx.payload.event.issue_number;
|
||||||
const isPlanMode = ctx.toolState.selectedMode === "Plan";
|
const isPlanMode = ctx.toolState.selectedMode === "Plan";
|
||||||
const isGitHubActions2 = !!process.env.GITHUB_ACTIONS;
|
|
||||||
if (existingCommentId) {
|
if (existingCommentId) {
|
||||||
const customParts = isPlanMode && issueNumber !== void 0 ? [buildImplementPlanLink(ctx.owner, ctx.name, issueNumber, existingCommentId)] : void 0;
|
const customParts = isPlanMode && issueNumber !== void 0 ? [buildImplementPlanLink(ctx.owner, ctx.name, issueNumber, existingCommentId)] : void 0;
|
||||||
const bodyWithoutFooter = stripExistingFooter(body);
|
const bodyWithoutFooter = stripExistingFooter(body);
|
||||||
@@ -106581,7 +106581,7 @@ async function reportProgress(ctx, { body }) {
|
|||||||
body: bodyWithFooter
|
body: bodyWithFooter
|
||||||
});
|
});
|
||||||
progressCommentWasUpdated = true;
|
progressCommentWasUpdated = true;
|
||||||
if (isGitHubActions2) await updateSummary(bodyWithFooter);
|
await updateSummary(bodyWithFooter);
|
||||||
return {
|
return {
|
||||||
commentId: result2.data.id,
|
commentId: result2.data.id,
|
||||||
url: result2.data.html_url,
|
url: result2.data.html_url,
|
||||||
@@ -106616,7 +106616,7 @@ async function reportProgress(ctx, { body }) {
|
|||||||
comment_id: result.data.id,
|
comment_id: result.data.id,
|
||||||
body: bodyWithPlanLink
|
body: bodyWithPlanLink
|
||||||
});
|
});
|
||||||
if (isGitHubActions2) await updateSummary(bodyWithPlanLink);
|
await updateSummary(bodyWithPlanLink);
|
||||||
return {
|
return {
|
||||||
commentId: updateResult.data.id,
|
commentId: updateResult.data.id,
|
||||||
url: updateResult.data.html_url,
|
url: updateResult.data.html_url,
|
||||||
@@ -106624,7 +106624,7 @@ async function reportProgress(ctx, { body }) {
|
|||||||
action: "created"
|
action: "created"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (isGitHubActions2) await updateSummary(initialBody);
|
await updateSummary(initialBody);
|
||||||
return {
|
return {
|
||||||
commentId: result.data.id,
|
commentId: result.data.id,
|
||||||
url: result.data.html_url,
|
url: result.data.html_url,
|
||||||
|
|||||||
+7
-6
@@ -15,6 +15,8 @@ import { execute, tool } from "./shared.ts";
|
|||||||
*/
|
*/
|
||||||
export const LEAPING_INTO_ACTION_PREFIX = "Leaping into action";
|
export const LEAPING_INTO_ACTION_PREFIX = "Leaping into action";
|
||||||
|
|
||||||
|
const isGitHubActions = !!process.env.GITHUB_ACTIONS;
|
||||||
|
|
||||||
interface BuildCommentFooterParams {
|
interface BuildCommentFooterParams {
|
||||||
payload: Payload;
|
payload: Payload;
|
||||||
octokit?: OctokitWithPlugins | undefined;
|
octokit?: OctokitWithPlugins | undefined;
|
||||||
@@ -190,8 +192,8 @@ export const ReportProgress = type({
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/** Updates job summary with the given text. */
|
/** Updates job summary with the given text if running in GitHub Actions. */
|
||||||
const updateSummary = (text: string) => core.summary.addRaw(text).write({ overwrite: true });
|
const updateSummary = (text: string) => isGitHubActions && core.summary.addRaw(text).write({ overwrite: true });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standalone function to report progress to GitHub comment.
|
* Standalone function to report progress to GitHub comment.
|
||||||
@@ -214,7 +216,6 @@ export async function reportProgress(
|
|||||||
const issueNumber =
|
const issueNumber =
|
||||||
ctx.toolState.prNumber ?? ctx.toolState.issueNumber ?? ctx.payload.event.issue_number;
|
ctx.toolState.prNumber ?? ctx.toolState.issueNumber ?? ctx.payload.event.issue_number;
|
||||||
const isPlanMode = ctx.toolState.selectedMode === "Plan";
|
const isPlanMode = ctx.toolState.selectedMode === "Plan";
|
||||||
const isGitHubActions = !!process.env.GITHUB_ACTIONS;
|
|
||||||
|
|
||||||
// if we already have a progress comment, update it
|
// if we already have a progress comment, update it
|
||||||
if (existingCommentId) {
|
if (existingCommentId) {
|
||||||
@@ -240,7 +241,7 @@ export async function reportProgress(
|
|||||||
|
|
||||||
progressCommentWasUpdated = true;
|
progressCommentWasUpdated = true;
|
||||||
|
|
||||||
if (isGitHubActions) await updateSummary(bodyWithFooter);
|
await updateSummary(bodyWithFooter);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
commentId: result.data.id,
|
commentId: result.data.id,
|
||||||
@@ -289,7 +290,7 @@ export async function reportProgress(
|
|||||||
body: bodyWithPlanLink,
|
body: bodyWithPlanLink,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isGitHubActions) await updateSummary(bodyWithPlanLink);
|
await updateSummary(bodyWithPlanLink);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
commentId: updateResult.data.id,
|
commentId: updateResult.data.id,
|
||||||
@@ -299,7 +300,7 @@ export async function reportProgress(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isGitHubActions) await updateSummary(initialBody);
|
await updateSummary(initialBody);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
commentId: result.data.id,
|
commentId: result.data.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user