ci: Post file stats on PRs (#32053)

This commit is contained in:
yehorkardash
2026-06-11 11:34:38 +00:00
committed by GitHub
parent 03aca697df
commit d0fc358f7e
6 changed files with 727 additions and 116 deletions
+54
View File
@@ -407,6 +407,60 @@ export async function getChangedFiles(pullRequestNumber) {
]);
}
/**
* Returns all files changed in a PR with full metadata including line counts.
*
* @param { number } pullRequestNumber
* @returns { Promise<Array<{ filename: string, additions: number, deletions: number, previous_filename?: string }>> }
* */
export async function getPrFiles(pullRequestNumber) {
const { octokit, owner, repo } = initGithub();
return await octokit.paginate(octokit.rest.pulls.listFiles, {
owner,
repo,
pull_number: pullRequestNumber,
per_page: 100,
});
}
/**
* Post a PR comment, or update the existing one if a previous run already
* left one identified by the provided bot marker.
*
* @param { number } pullRequestNumber
* @param { string } body
* @param { string } botMarker
*/
export async function postOrUpdateComment(pullRequestNumber, body, botMarker) {
const { octokit, owner, repo } = initGithub();
const comments = await octokit.paginate(octokit.rest.issues.listComments, {
owner,
repo,
issue_number: pullRequestNumber,
per_page: 100,
});
const existing = comments.find((c) => c.body?.includes(botMarker));
if (existing) {
await octokit.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
} else {
await octokit.rest.issues.createComment({
owner,
repo,
issue_number: pullRequestNumber,
body,
});
}
}
/**
* @param {string} tag
*/