From 690428f56964da346393fe69f8b1ac685d80b803 Mon Sep 17 00:00:00 2001 From: Yusuf Ali Date: Sat, 10 Jan 2026 05:14:21 +0000 Subject: [PATCH] fix: corrected limit for drawing comments --- dist/index.js | 17 +++++++++++++++-- index.js | 17 +++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index ea17abd..19be62b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32861,7 +32861,7 @@ const serverUrl = ( async function issueComments() { if (!repoFullName || !issueNumber) return null; - const url = `${serverUrl}/api/v1/repos/${repoFullName}/issues/${issueNumber}/comments?limit=1`; + const url = `${serverUrl}/api/v1/repos/${repoFullName}/issues/${issueNumber}/comments?limit=30`; const headers = { Accept: "application/vnd.github+json" }; if (githubToken) { @@ -32880,7 +32880,20 @@ async function issueComments() { const comments = await response.json(); if (!Array.isArray(comments) || comments.length === 0) return null; - return comments.map((v) => v.body); + const sortedComments = comments + .slice() + .sort((a, b) => { + if (a?.created_at && b?.created_at) { + return new Date(a.created_at) - new Date(b.created_at); + } + if (Number.isFinite(a?.id) && Number.isFinite(b?.id)) { + return a.id - b.id; + } + return 0; + }) + .map((v) => v.body); + + return sortedComments; } catch (error) { core.warning(`Error fetching issue comments: ${error}`); return null; diff --git a/index.js b/index.js index 6d586ad..5a00b2b 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,7 @@ const serverUrl = ( async function issueComments() { if (!repoFullName || !issueNumber) return null; - const url = `${serverUrl}/api/v1/repos/${repoFullName}/issues/${issueNumber}/comments?limit=1`; + const url = `${serverUrl}/api/v1/repos/${repoFullName}/issues/${issueNumber}/comments?limit=30`; const headers = { Accept: "application/vnd.github+json" }; if (githubToken) { @@ -48,7 +48,20 @@ async function issueComments() { const comments = await response.json(); if (!Array.isArray(comments) || comments.length === 0) return null; - return comments.map((v) => v.body); + const sortedComments = comments + .slice() + .sort((a, b) => { + if (a?.created_at && b?.created_at) { + return new Date(a.created_at) - new Date(b.created_at); + } + if (Number.isFinite(a?.id) && Number.isFinite(b?.id)) { + return a.id - b.id; + } + return 0; + }) + .map((v) => v.body); + + return sortedComments; } catch (error) { core.warning(`Error fetching issue comments: ${error}`); return null;