Skip to content

Commit

Permalink
Exclude blobs without sha when getting PR files
Browse files Browse the repository at this point in the history
Example: setting the exec bit on a file
  • Loading branch information
SkyTrix committed Jul 6, 2022
1 parent c8336a0 commit bbf330d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
5 changes: 4 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12806,7 +12806,10 @@ async function getPrFilesWithBlobSize(pullRequestNumber) {
return !isExcluded;
})
: data;
const prFilesWithBlobSize = await Promise.all(files.map(async (file) => {
const prFilesWithBlobSize = await Promise.all(files
// Cannot get blobs for files without sha (e.g. happens when only changing a permission bit on the file)
.filter(file => file.sha != null)
.map(async (file) => {
const { filename, sha, patch } = file;
const { data: blob } = await octokit.rest.git.getBlob({
...repo,
Expand Down
31 changes: 17 additions & 14 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,24 @@ async function getPrFilesWithBlobSize(pullRequestNumber: number) {
: data;

const prFilesWithBlobSize = await Promise.all(
files.map(async file => {
const {filename, sha, patch} = file;
const {data: blob} = await octokit.rest.git.getBlob({
...repo,
file_sha: sha,
});
files
// Cannot get blobs for files without sha (e.g. happens when only changing a permission bit on the file)
.filter(file => file.sha != null)
.map(async file => {
const {filename, sha, patch} = file;
const {data: blob} = await octokit.rest.git.getBlob({
...repo,
file_sha: sha,
});

return {
filename,
filesha: sha,
fileblobsize: blob.size,
filecontents: blob.content,
patch,
};
})
return {
filename,
filesha: sha,
fileblobsize: blob.size,
filecontents: blob.content,
patch,
};
})
);
return prFilesWithBlobSize;
}
Expand Down

0 comments on commit bbf330d

Please sign in to comment.