From dd2bf2665e1e738143fe8aae97d4a658b0247332 Mon Sep 17 00:00:00 2001 From: JaeSeoKim Date: Thu, 19 Aug 2021 21:24:03 +0900 Subject: [PATCH] fix: duplicate variable name --- dist/index.js | 20 ++++++++++++-------- lib/pr-checker.js | 20 ++++++++++++-------- src/pr-checker.ts | 10 +++++----- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/dist/index.js b/dist/index.js index c34ded9..1566dca 100644 --- a/dist/index.js +++ b/dist/index.js @@ -86,7 +86,7 @@ var REASON = { LATE_SUBMISSION: "late-submission", }; var run = function () { return __awaiter(void 0, void 0, void 0, function () { - var token, currectLabel_1, wrongLabel_1, configPath, prNumber, client, config, pr, changedFiles, subjects, removeLabels, _loop_1, _i, _a, _b, key, subject_1, subject, _c, _d, label, error_1; + var token, currectLabel_1, wrongLabel_1, configPath, prNumber, client, config, pr, changedFiles, subjects, removeLabels, _loop_1, _i, _a, _b, key, subject_1, subject, _loop_2, _c, _d, reason, error_1; return __generator(this, function (_e) { switch (_e.label) { case 0: @@ -183,18 +183,22 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { _e.sent(); core.info("PR " + prNumber + ": late submission"); return [2 /*return*/]; - case 11: return [4 /*yield*/, exports.addLabels(client, prNumber, [subjects[0], currectLabel_1])]; - case 12: - _e.sent(); + case 11: if (pr.labels.find(function (label) { return label.name === wrongLabel_1; })) { exports.removeLabel(client, prNumber, wrongLabel_1); } - for (_c = 0, _d = Object.values(REASON); _c < _d.length; _c++) { - label = _d[_c]; - if (pr.labels.find(function (label) { return label.name === label; })) { - exports.removeLabel(client, prNumber, label); + _loop_2 = function (reason) { + if (pr.labels.find(function (label) { return label.name === reason; })) { + exports.removeLabel(client, prNumber, reason); } + }; + for (_c = 0, _d = Object.values(REASON); _c < _d.length; _c++) { + reason = _d[_c]; + _loop_2(reason); } + return [4 /*yield*/, exports.addLabels(client, prNumber, [subjects[0], currectLabel_1])]; + case 12: + _e.sent(); return [4 /*yield*/, exports.addComment(client, prNumber, [ !!pr.user && "\uD83D\uDC4B \uC548\uB155\uD558\uC138\uC694! " + pr.user.login + "\uB2D8!", "- \uD83C\uDF89 \uC815\uC0C1\uC801\uC73C\uB85C \uC81C\uCD9C \uB418\uC168\uC2B5\uB2C8\uB2E4! \uD3C9\uAC00 \uB9E4\uCE6D\uC744 \uAE30\uB2EC\uB824\uC8FC\uC138\uC694!", diff --git a/lib/pr-checker.js b/lib/pr-checker.js index e760a5f..bb70846 100644 --- a/lib/pr-checker.js +++ b/lib/pr-checker.js @@ -79,7 +79,7 @@ var REASON = { LATE_SUBMISSION: "late-submission", }; var run = function () { return __awaiter(void 0, void 0, void 0, function () { - var token, currectLabel_1, wrongLabel_1, configPath, prNumber, client, config, pr, changedFiles, subjects, removeLabels, _loop_1, _i, _a, _b, key, subject_1, subject, _c, _d, label, error_1; + var token, currectLabel_1, wrongLabel_1, configPath, prNumber, client, config, pr, changedFiles, subjects, removeLabels, _loop_1, _i, _a, _b, key, subject_1, subject, _loop_2, _c, _d, reason, error_1; return __generator(this, function (_e) { switch (_e.label) { case 0: @@ -176,18 +176,22 @@ var run = function () { return __awaiter(void 0, void 0, void 0, function () { _e.sent(); core.info("PR " + prNumber + ": late submission"); return [2 /*return*/]; - case 11: return [4 /*yield*/, exports.addLabels(client, prNumber, [subjects[0], currectLabel_1])]; - case 12: - _e.sent(); + case 11: if (pr.labels.find(function (label) { return label.name === wrongLabel_1; })) { exports.removeLabel(client, prNumber, wrongLabel_1); } - for (_c = 0, _d = Object.values(REASON); _c < _d.length; _c++) { - label = _d[_c]; - if (pr.labels.find(function (label) { return label.name === label; })) { - exports.removeLabel(client, prNumber, label); + _loop_2 = function (reason) { + if (pr.labels.find(function (label) { return label.name === reason; })) { + exports.removeLabel(client, prNumber, reason); } + }; + for (_c = 0, _d = Object.values(REASON); _c < _d.length; _c++) { + reason = _d[_c]; + _loop_2(reason); } + return [4 /*yield*/, exports.addLabels(client, prNumber, [subjects[0], currectLabel_1])]; + case 12: + _e.sent(); return [4 /*yield*/, exports.addComment(client, prNumber, [ !!pr.user && "\uD83D\uDC4B \uC548\uB155\uD558\uC138\uC694! " + pr.user.login + "\uB2D8!", "- \uD83C\uDF89 \uC815\uC0C1\uC801\uC73C\uB85C \uC81C\uCD9C \uB418\uC168\uC2B5\uB2C8\uB2E4! \uD3C9\uAC00 \uB9E4\uCE6D\uC744 \uAE30\uB2EC\uB824\uC8FC\uC138\uC694!", diff --git a/src/pr-checker.ts b/src/pr-checker.ts index c56d1ec..f6862e6 100644 --- a/src/pr-checker.ts +++ b/src/pr-checker.ts @@ -152,18 +152,18 @@ export const run = async () => { return; } - await addLabels(client, prNumber, [subjects[0], currectLabel]); - if (pr.labels.find((label) => label.name === wrongLabel)) { removeLabel(client, prNumber, wrongLabel); } - for (const label of Object.values(REASON)) { - if (pr.labels.find((label) => label.name === label)) { - removeLabel(client, prNumber, label); + for (const reason of Object.values(REASON)) { + if (pr.labels.find((label) => label.name === reason)) { + removeLabel(client, prNumber, reason); } } + await addLabels(client, prNumber, [subjects[0], currectLabel]); + await addComment( client, prNumber,