diff --git a/dist/index.js b/dist/index.js index f8e7a28..1339667 100644 --- a/dist/index.js +++ b/dist/index.js @@ -375,7 +375,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(__webpack_require__(470)); const github = __importStar(__webpack_require__(469)); function removeExistingApprovalsIfExist(client, pr) { - var _a, _b, _c, _d; + var _a, _b, _c; return __awaiter(this, void 0, void 0, function* () { // Get list of all reviews on a PR const { data: listReviews } = yield client.rest.pulls.listReviews({ @@ -396,47 +396,19 @@ function removeExistingApprovalsIfExist(client, pr) { }); // Remove PR approvals by any committer to the PR for (let review of listReviews) { - core.info(`review.id: ${review.id}`); - core.info(`review.state: ${review.state}`); - core.info(`review.pull_request_url: ${review.pull_request_url}`); - core.info(`review.user.login: ${(_a = review.user) === null || _a === void 0 ? void 0 : _a.login}`); - core.info(`commitAuthorLogins: ${commitAuthorLogins}`); if (review.state === 'APPROVED' && review.user && commitAuthorLogins.includes(review.user.login)) { - core.info(`Removing an approval from ${(_b = review.user) === null || _b === void 0 ? void 0 : _b.login} (cannot approve this PR since they committed to it)`); - // core.info(`review.body: ${review.body}`); - // if (review.body.length > 0) { - // core.info( - // `Moving review comment to a new comment in order to dismiss review.` - // ); - // const { data: submitReview } = await client.rest.pulls.submitReview({ - // owner: github.context.repo.owner, - // repo: github.context.repo.repo, - // pull_number: pr.number, - // review_id: review.id, - // body: `Moving review comment by ${review.user?.login} to a new comment in order to dismiss review:\n\nreview.body`, - // event: 'COMMENT', - // }); - // core.debug(`submitReview: ${JSON.stringify(submitReview)}`); - // const { data: updateReview } = await client.rest.pulls.updateReview({ - // owner: github.context.repo.owner, - // repo: github.context.repo.repo, - // pull_number: pr.number, - // review_id: review.id, - // body: '', - // }); - // core.debug(`updateReview: ${JSON.stringify(updateReview)}`); - // } + core.info(`Removing an approval (${review.id}) from ${(_a = review.user) === null || _a === void 0 ? void 0 : _a.login} (cannot approve this PR since they committed to it)`); const dismissResponse = yield client.rest.pulls.dismissReview({ owner: github.context.repo.owner, repo: github.context.repo.repo, pull_number: pr.number, review_id: review.id, - message: `${(_c = review.user) === null || _c === void 0 ? void 0 : _c.login} cannot approve this PR since they committed to it`, + message: `${(_b = review.user) === null || _b === void 0 ? void 0 : _b.login} cannot approve this PR since they committed to it`, }); core.debug(`dismissResponse: ${JSON.stringify(dismissResponse)}`); - core.setFailed(`${(_d = review.user) === null || _d === void 0 ? void 0 : _d.login} cannot approve this PR since they committed to it`); + core.setFailed(`${(_c = review.user) === null || _c === void 0 ? void 0 : _c.login} cannot approve this PR since they committed to it`); } } }); diff --git a/src/main.ts b/src/main.ts index 0b0299d..ed27626 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,42 +25,14 @@ async function removeExistingApprovalsIfExist(client: GitHub, pr: any) { // Remove PR approvals by any committer to the PR for (let review of listReviews) { - core.info(`review.id: ${review.id}`); - core.info(`review.state: ${review.state}`); - core.info(`review.pull_request_url: ${review.pull_request_url}`); - core.info(`review.user.login: ${review.user?.login}`); - core.info(`commitAuthorLogins: ${commitAuthorLogins}`); if ( review.state === 'APPROVED' && review.user && commitAuthorLogins.includes(review.user.login) ) { core.info( - `Removing an approval from ${review.user?.login} (cannot approve this PR since they committed to it)` + `Removing an approval (${review.id}) from ${review.user?.login} (cannot approve this PR since they committed to it)` ); - // core.info(`review.body: ${review.body}`); - // if (review.body.length > 0) { - // core.info( - // `Moving review comment to a new comment in order to dismiss review.` - // ); - // const { data: submitReview } = await client.rest.pulls.submitReview({ - // owner: github.context.repo.owner, - // repo: github.context.repo.repo, - // pull_number: pr.number, - // review_id: review.id, - // body: `Moving review comment by ${review.user?.login} to a new comment in order to dismiss review:\n\nreview.body`, - // event: 'COMMENT', - // }); - // core.debug(`submitReview: ${JSON.stringify(submitReview)}`); - // const { data: updateReview } = await client.rest.pulls.updateReview({ - // owner: github.context.repo.owner, - // repo: github.context.repo.repo, - // pull_number: pr.number, - // review_id: review.id, - // body: '', - // }); - // core.debug(`updateReview: ${JSON.stringify(updateReview)}`); - // } const dismissResponse = await client.rest.pulls.dismissReview({ owner: github.context.repo.owner, repo: github.context.repo.repo,