Skip to content

Commit

Permalink
Fix parameters of repos.getContent API (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
LitoMore authored Dec 22, 2024
1 parent 413d2e0 commit 4aaf082
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/index.mjs

Large diffs are not rendered by default.

14 changes: 10 additions & 4 deletions src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ async function getPrFiles(core, client, context, prNumber) {
patch: fileInfo.patch,
path: fileInfo.filename,
status: fileInfo.status,
contentsUrl: fileInfo.contents_url,
});
} catch (err) {
core.warning(
Expand All @@ -180,6 +181,7 @@ async function getPrFiles(core, client, context, prNumber) {
patch: fileInfo.patch,
path: fileInfo.filename,
status: fileInfo.status,
contentsUrl: fileInfo.contents_url,
});
} catch (err) {
core.warning(
Expand All @@ -202,6 +204,7 @@ async function getPrFiles(core, client, context, prNumber) {
patch: dataFile.patch,
path: dataFile.filename,
status: dataFile.status,
contentsUrl: dataFile.contents_url,
});
}

Expand Down Expand Up @@ -322,13 +325,16 @@ async function getChangesFromFile(core, file, client, context, id) {
const contentResult = await client.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
path: file.filename,
ref: file.sha,
path: file.path,
ref: new URL(file.contentsUrl).searchParams.get('ref'),
});

filePatch = Buffer.from(
contentResult.content,
contentResult.encoding,
// The content is base64 encoded but splited with newlines, so we need to remove them before decoding
contentResult.data.encoding === 'base64'
? contentResult.data.content.replaceAll('\n', '')
: contentResult.data.content,
contentResult.data.encoding,
).toString();
}

Expand Down

0 comments on commit 4aaf082

Please sign in to comment.