From 29d31f4c0c0765cd2b82113e53d2d7fcbb9062fc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:24:52 +0900 Subject: [PATCH] =?UTF-8?q?format=E4=BF=AE=E6=AD=A3=20(#1816)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- dist/assign_a_user.js | 3 +- dist/close_pull_request.js | 64 ++++++++++++----------------- dist/create_pull_request.js | 52 +++++++++-------------- dist/generate_title_description.js | 3 +- dist/get_number_of_pull_requests.js | 22 +++------- dist/get_pull_requests.js | 3 +- dist/update_pull_request.js | 46 ++++++++------------- package-lock.json | 8 ---- 8 files changed, 71 insertions(+), 130 deletions(-) diff --git a/dist/assign_a_user.js b/dist/assign_a_user.js index 447c1979..f8941f74 100644 --- a/dist/assign_a_user.js +++ b/dist/assign_a_user.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; async function script(github, context) { const issuesAddAssigneesParams = { owner: context.repo.owner, @@ -12,4 +12,3 @@ async function script(github, context) { console.log(issuesAddAssigneesParams); await github.rest.issues.addAssignees(issuesAddAssigneesParams); } -exports.script = script; diff --git a/dist/close_pull_request.js b/dist/close_pull_request.js index 60581585..0e5ba307 100644 --- a/dist/close_pull_request.js +++ b/dist/close_pull_request.js @@ -1,42 +1,30 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; const get_pull_requests_1 = require("./get_pull_requests"); -function script(github, context) { - return __awaiter(this, void 0, void 0, function* () { - const HEAD_REF = process.env.HEAD_REF; - let headName = process.env.BRANCH_NAME_PREFIX; - if (HEAD_REF !== "") { - headName += "-" + HEAD_REF; - } - for (const pull of yield (0, get_pull_requests_1.getPullRequests)(github, context)) { - // 修正PRをcloseする (修正PRのstateをclosedに更新する) - const pullsUpdateParams = { - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pull.number, - state: "closed", - }; - console.log("call pulls.update:", pullsUpdateParams); - yield github.rest.pulls.update(pullsUpdateParams); - // 修正PRのブランチを削除する - const gitDeleteRefParams = { - owner: context.repo.owner, - repo: context.repo.repo, - ref: "heads/" + headName, - }; - console.log("call git.deleteRef:", gitDeleteRefParams); - yield github.rest.git.deleteRef(gitDeleteRefParams); - } - }); +async function script(github, context) { + const HEAD_REF = process.env.HEAD_REF; + let headName = process.env.BRANCH_NAME_PREFIX; + if (HEAD_REF !== "") { + headName += "-" + HEAD_REF; + } + for (const pull of await (0, get_pull_requests_1.getPullRequests)(github, context)) { + // 修正PRをcloseする (修正PRのstateをclosedに更新する) + const pullsUpdateParams = { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull.number, + state: "closed", + }; + console.log("call pulls.update:", pullsUpdateParams); + await github.rest.pulls.update(pullsUpdateParams); + // 修正PRのブランチを削除する + const gitDeleteRefParams = { + owner: context.repo.owner, + repo: context.repo.repo, + ref: "heads/" + headName, + }; + console.log("call git.deleteRef:", gitDeleteRefParams); + await github.rest.git.deleteRef(gitDeleteRefParams); + } } -exports.script = script; diff --git a/dist/create_pull_request.js b/dist/create_pull_request.js index 5726d507..c5ca89df 100644 --- a/dist/create_pull_request.js +++ b/dist/create_pull_request.js @@ -1,36 +1,24 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; const generate_title_description_1 = require("./generate_title_description"); -function script(github, context) { - return __awaiter(this, void 0, void 0, function* () { - const HEAD_REF = process.env.HEAD_REF || ""; - let head = process.env.BRANCH_NAME_PREFIX; - if (HEAD_REF !== "") { - head += "-" + HEAD_REF; - } - const headWithRepo = context.repo.owner + ":" + head; - const { title, body } = (0, generate_title_description_1.generateTitleDescription)(); - const pullsCreateParams = { - owner: context.repo.owner, - repo: context.repo.repo, - head: headWithRepo, - base: HEAD_REF, - title, - body, - }; - console.log("call pulls.create:", pullsCreateParams); - const createPullRes = yield github.rest.pulls.create(pullsCreateParams); - return createPullRes.data.number; - }); +async function script(github, context) { + const HEAD_REF = process.env.HEAD_REF || ""; + let head = process.env.BRANCH_NAME_PREFIX; + if (HEAD_REF !== "") { + head += "-" + HEAD_REF; + } + const headWithRepo = context.repo.owner + ":" + head; + const { title, body } = (0, generate_title_description_1.generateTitleDescription)(); + const pullsCreateParams = { + owner: context.repo.owner, + repo: context.repo.repo, + head: headWithRepo, + base: HEAD_REF, + title, + body, + }; + console.log("call pulls.create:", pullsCreateParams); + const createPullRes = await github.rest.pulls.create(pullsCreateParams); + return createPullRes.data.number; } -exports.script = script; diff --git a/dist/generate_title_description.js b/dist/generate_title_description.js index d16d42ed..3ec3e49f 100644 --- a/dist/generate_title_description.js +++ b/dist/generate_title_description.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.generateTitleDescription = void 0; +exports.generateTitleDescription = generateTitleDescription; function generateTitleDescription() { const HEAD_REF = process.env.HEAD_REF || ""; const escapedHeadRef = HEAD_REF.replace(/#/g, ""); @@ -48,4 +48,3 @@ function generateTitleDescription() { body, }; } -exports.generateTitleDescription = generateTitleDescription; diff --git a/dist/get_number_of_pull_requests.js b/dist/get_number_of_pull_requests.js index 27bde214..80e7c436 100644 --- a/dist/get_number_of_pull_requests.js +++ b/dist/get_number_of_pull_requests.js @@ -1,21 +1,9 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; const get_pull_requests_1 = require("./get_pull_requests"); -function script(github, context) { - return __awaiter(this, void 0, void 0, function* () { - const HEAD_REF = process.env.HEAD_REF; - const pulls = yield (0, get_pull_requests_1.getPullRequests)(github, context, HEAD_REF); - return pulls.length; - }); +async function script(github, context) { + const HEAD_REF = process.env.HEAD_REF; + const pulls = await (0, get_pull_requests_1.getPullRequests)(github, context, HEAD_REF); + return pulls.length; } -exports.script = script; diff --git a/dist/get_pull_requests.js b/dist/get_pull_requests.js index 7faa002f..ce297f4d 100644 --- a/dist/get_pull_requests.js +++ b/dist/get_pull_requests.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getPullRequests = void 0; +exports.getPullRequests = getPullRequests; async function getPullRequests(github, context, base) { const HEAD_REF = process.env.HEAD_REF; let head = context.repo.owner + ":" + process.env.BRANCH_NAME_PREFIX; @@ -17,4 +17,3 @@ async function getPullRequests(github, context, base) { console.log("call pulls.list:", pullsListParams); return await github.paginate(github.rest.pulls.list, pullsListParams); } -exports.getPullRequests = getPullRequests; diff --git a/dist/update_pull_request.js b/dist/update_pull_request.js index 149b6b0f..c03e39cb 100644 --- a/dist/update_pull_request.js +++ b/dist/update_pull_request.js @@ -1,35 +1,23 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; const generate_title_description_1 = require("./generate_title_description"); const get_pull_requests_1 = require("./get_pull_requests"); -function script(github, context) { - return __awaiter(this, void 0, void 0, function* () { - const { title, body } = (0, generate_title_description_1.generateTitleDescription)(); - for (const pull of yield (0, get_pull_requests_1.getPullRequests)(github, context)) { - if (pull.title === title && pull.body === body) { - continue; - } - // PRのタイトルやDescriptionを更新する - const pullsUpdateParams = { - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pull.number, - title, - body, - }; - console.log("call pulls.update:", pullsUpdateParams); - yield github.rest.pulls.update(pullsUpdateParams); +async function script(github, context) { + const { title, body } = (0, generate_title_description_1.generateTitleDescription)(); + for (const pull of await (0, get_pull_requests_1.getPullRequests)(github, context)) { + if (pull.title === title && pull.body === body) { + continue; } - }); + // PRのタイトルやDescriptionを更新する + const pullsUpdateParams = { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull.number, + title, + body, + }; + console.log("call pulls.update:", pullsUpdateParams); + await github.rest.pulls.update(pullsUpdateParams); + } } -exports.script = script; diff --git a/package-lock.json b/package-lock.json index 3ca60ce1..da3fbf28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7564,14 +7564,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/try-resolve": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/try-resolve/-/try-resolve-1.0.1.tgz", - "integrity": "sha512-yHeaPjCBzVaXwWl5IMUapTaTC2rn/eBYg2fsG2L+CvJd+ttFbk0ylDnpTO3wVhosmE1tQEvcebbBeKLCwScQSQ==", - "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", - "dev": true, - "license": "MIT" - }, "node_modules/tsc": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.4.tgz",