diff --git a/.circleci/config.yml b/.circleci/config.yml index 3438e2279..44da460f0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -574,7 +574,7 @@ jobs: command: | echo -e "\\x1B[36mInstalling additional dependencies\\x1B[0m" sudo apt-get install -y shellcheck - yarn add @octokit/rest@15.10.0 + yarn add @octokit/rest@15.18.0 echo -e "\\x1B[36mAnalyzing shell scripts\\x1B[0m"; \ GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" \ GITHUB_OWNER="$CIRCLE_PROJECT_USERNAME" \ @@ -586,7 +586,7 @@ jobs: - run: name: Analyze Code command: | - echo -e "\\x1B[36mInstalling additional dependencies\\x1B[0m"; yarn add @octokit/rest@15.10.0 + echo -e "\\x1B[36mInstalling additional dependencies\\x1B[0m"; yarn add @octokit/rest@15.18.0 echo -e "\\x1B[36mAnalyzing code\\x1B[0m"; \ GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" \ GITHUB_OWNER="$CIRCLE_PROJECT_USERNAME" \ diff --git a/scripts/circleci/code-analysis-bot.js b/scripts/circleci/code-analysis-bot.js index 86f21ab69..eb003f5fb 100644 --- a/scripts/circleci/code-analysis-bot.js +++ b/scripts/circleci/code-analysis-bot.js @@ -118,19 +118,17 @@ function getShaFromPullRequest(owner, repo, number, callback) { }); } -function getFilesFromCommit(owner, repo, sha, callback) { - octokit.repos.getCommit({owner, repo, sha}, (error, res) => { - if (error) { - console.error(error); - return; - } - // A merge commit should not have any new changes to report - if (res.parents && res.parents.length > 1) { - return; - } - - callback(res.data.files); - }); +function getFilesFromPullRequest(owner, repo, number, callback) { + octokit.pullRequests.listFiles( + {owner, repo, number, per_page: 100}, + (error, res) => { + if (error) { + console.error(error); + return; + } + callback(res.data); + }, + ); } /** @@ -227,7 +225,7 @@ function main(messages, owner, repo, number) { } getShaFromPullRequest(owner, repo, number, sha => { - getFilesFromCommit(owner, repo, sha, files => { + getFilesFromPullRequest(owner, repo, number, files => { let comments = []; let convertersUsed = []; files.filter(file => messages[file.filename]).forEach(file => { @@ -256,7 +254,7 @@ function main(messages, owner, repo, number) { }); sendReview(owner, repo, number, sha, body, comments); - }); // getFilesFromCommit + }); // getFilesFromPullRequest }); // getShaFromPullRequest }