Skip to content

Commit

Permalink
Always do filter
Browse files Browse the repository at this point in the history
  • Loading branch information
orktes committed Feb 10, 2022
1 parent d1849e2 commit f565df1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 31 deletions.
24 changes: 10 additions & 14 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12719,20 +12719,16 @@ async function getPrFilesWithBlobSize(pullRequestNumber) {
pull_number: pullRequestNumber,
});
const exclusionPatterns = core.getMultilineInput('exclusionPatterns');
const files = exclusionPatterns.length > 0
? data.filter(({ filename, status }) => {
if (status === 'copied' ||
status === 'renamed' ||
status === 'removed') {
return false;
}
const isExcluded = micromatch.isMatch(filename, exclusionPatterns);
if (isExcluded) {
core.info(`${filename} has been excluded from LFS warning`);
}
return !isExcluded;
})
: data;
const files = data.filter(({ filename, status }) => {
if (status === 'copied' || status === 'renamed' || status === 'removed') {
return false;
}
const isExcluded = micromatch.isMatch(filename, exclusionPatterns);
if (isExcluded) {
core.info(`${filename} has been excluded from LFS warning`);
}
return !isExcluded;
});
const prFilesWithBlobSize = await Promise.all(files.map(async (file) => {
const { filename, sha, patch, status } = file;
const { data: blob } = await octokit.rest.git.getBlob({
Expand Down
27 changes: 10 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,17 @@ async function getPrFilesWithBlobSize(pullRequestNumber: number) {

const exclusionPatterns = core.getMultilineInput('exclusionPatterns');

const files =
exclusionPatterns.length > 0
? data.filter(({filename, status}) => {
if (
status === 'copied' ||
status === 'renamed' ||
status === 'removed'
) {
return false;
}
const files = data.filter(({filename, status}) => {
if (status === 'copied' || status === 'renamed' || status === 'removed') {
return false;
}

const isExcluded = micromatch.isMatch(filename, exclusionPatterns);
if (isExcluded) {
core.info(`${filename} has been excluded from LFS warning`);
}
return !isExcluded;
})
: data;
const isExcluded = micromatch.isMatch(filename, exclusionPatterns);
if (isExcluded) {
core.info(`${filename} has been excluded from LFS warning`);
}
return !isExcluded;
});

const prFilesWithBlobSize = await Promise.all(
files.map(async file => {
Expand Down

0 comments on commit f565df1

Please sign in to comment.