diff --git a/dist/index.js b/dist/index.js index 60379cb..d6fc71a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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, diff --git a/package-lock.json b/package-lock.json index 88c88a2..0561942 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "3.1.0", "license": "MIT", "dependencies": { - "@actions/core": "^1.5.0", + "@actions/core": "^1.9.1", "@actions/github": "^5.0.0", "micromatch": "^4.0.4" }, @@ -24,9 +24,21 @@ } }, "node_modules/@actions/core": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.5.0.tgz", - "integrity": "sha512-eDOLH1Nq9zh+PJlYLqEMkS/jLQxhksPNmUGNBHfa4G+tQmnIhzpctxmchETtVGyBOvXgOVVpYuE40+eS4cUnwQ==" + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", + "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "dependencies": { + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" + } + }, + "node_modules/@actions/core/node_modules/@actions/http-client": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz", + "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==", + "dependencies": { + "tunnel": "^0.0.6" + } }, "node_modules/@actions/github": { "version": "5.0.0", @@ -6468,6 +6480,14 @@ "node": ">=4" } }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/v8-compile-cache": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", @@ -6732,9 +6752,23 @@ }, "dependencies": { "@actions/core": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.5.0.tgz", - "integrity": "sha512-eDOLH1Nq9zh+PJlYLqEMkS/jLQxhksPNmUGNBHfa4G+tQmnIhzpctxmchETtVGyBOvXgOVVpYuE40+eS4cUnwQ==" + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", + "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "requires": { + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" + }, + "dependencies": { + "@actions/http-client": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz", + "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==", + "requires": { + "tunnel": "^0.0.6" + } + } + } }, "@actions/github": { "version": "5.0.0", @@ -11658,6 +11692,11 @@ "prepend-http": "^2.0.0" } }, + "uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==" + }, "v8-compile-cache": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz", diff --git a/package.json b/package.json index c1f316e..481b71e 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "homepage": "https://github.com/ppremk/lfs-warning#readme", "dependencies": { - "@actions/core": "^1.5.0", + "@actions/core": "^1.9.1", "@actions/github": "^5.0.0", "micromatch": "^4.0.4" }, diff --git a/src/index.ts b/src/index.ts index 5774813..4cb26b2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; }