From b3b17b23cc621dd0fe68f78d12debe995091959b Mon Sep 17 00:00:00 2001 From: Christopher David Date: Thu, 29 Aug 2024 12:36:19 -0500 Subject: [PATCH] fix that mayeb --- lib/githubUtils.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/githubUtils.ts b/lib/githubUtils.ts index 3100eca0..21bb61d3 100644 --- a/lib/githubUtils.ts +++ b/lib/githubUtils.ts @@ -102,18 +102,16 @@ export async function githubDeleteFile(args: { committerEmail = "noreply@github.com" } = args; - // Include the branch in the URL when fetching the file data - const getFileUrl = `https://api.github.com/repos/${repoOwner}/${repoName}/contents/${path}?ref=${branch}`; + // Include the branch in the URL for both GET and DELETE requests + const fileUrl = `https://api.github.com/repos/${repoOwner}/${repoName}/contents/${path}`; // First, get the current file to retrieve its SHA - const fileData = await githubApiRequest(getFileUrl, token); + const fileData = await githubApiRequest(`${fileUrl}?ref=${branch}`, token); if (!fileData.sha) { throw new Error(`File not found: ${path} in branch ${branch}`); } - const deleteUrl = `https://api.github.com/repos/${repoOwner}/${repoName}/contents/${path}`; - // Prepare the request body const body = { message: message || `Delete ${path}`, @@ -126,5 +124,5 @@ export async function githubDeleteFile(args: { }; // Send DELETE request - await githubApiRequest(deleteUrl, token, 'DELETE', body); + await githubApiRequest(fileUrl, token, 'DELETE', body); }