From 0833ab17f7c589f03477ed1dac7d2b4494738796 Mon Sep 17 00:00:00 2001 From: Sahil Lavingia Date: Wed, 25 Sep 2024 11:33:38 -0400 Subject: [PATCH] cp --- lib/github.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/github.ts b/lib/github.ts index 7832364a..7c2b4307 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -289,7 +289,7 @@ export async function getPullRequestInfo( while (queue.length > 0) { const item = queue.shift(); - if (item.type === "dir") { + if (item && item.type === "dir") { const dirContents = await octokit.rest.repos.getContent({ owner, repo, @@ -297,6 +297,7 @@ export async function getPullRequestInfo( }); queue.push(...(dirContents.data as { path: string; type: string }[])); } else if ( + item && item.type === "file" && item.path.toLowerCase().includes(".test.") ) { @@ -304,12 +305,21 @@ export async function getPullRequestInfo( owner, repo, path: item.path, - mediaType: { format: "raw" }, - }); - testFiles.push({ - name: item.path, - content: fileContent.data as string, }); + + if ( + "content" in fileContent.data && + typeof fileContent.data.content === "string" + ) { + const decodedContent = Buffer.from( + fileContent.data.content, + "base64" + ).toString("utf-8"); + testFiles.push({ + name: item.path, + content: decodedContent, + }); + } } }