Skip to content

Commit

Permalink
fix that mayeb
Browse files Browse the repository at this point in the history
  • Loading branch information
AtlantisPleb committed Aug 29, 2024
1 parent 7fc7997 commit b3b17b2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/githubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand All @@ -126,5 +124,5 @@ export async function githubDeleteFile(args: {
};

// Send DELETE request
await githubApiRequest(deleteUrl, token, 'DELETE', body);
await githubApiRequest(fileUrl, token, 'DELETE', body);
}

0 comments on commit b3b17b2

Please sign in to comment.