From 16c18d48b68cba4d828983f3a74c89c80e246974 Mon Sep 17 00:00:00 2001 From: D3I Date: Thu, 2 May 2024 19:23:42 +0900 Subject: [PATCH] fix base option from head option with `org:` (#47) --- src/github-client.ts | 2 +- test/github-client.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/github-client.ts b/src/github-client.ts index 913fed2..f68b8d0 100644 --- a/src/github-client.ts +++ b/src/github-client.ts @@ -169,7 +169,7 @@ export default class GithubClient { return await this.get(this.pullRequestEndpoint(), { state: "closed", - base: this.head, + base: this.head.split(":").at(-1), per_page: 100, sort: "updated", direction: "desc", diff --git a/test/github-client.ts b/test/github-client.ts index a095038..f1452d2 100644 --- a/test/github-client.ts +++ b/test/github-client.ts @@ -177,6 +177,32 @@ describe("GithubClient", function () { }); }); + describe("#collectReleasePRs(): head option with `org:`", function () { + nock("https://api.github.com") + .get("/repos/uiureo/awesome-app/pulls/42/commits") + .query(true) + .reply(200, []) + .get( + "/repos/uiureo/awesome-app/pulls?state=closed&base=branch&per_page=100&sort=updated&direction=desc" + ) + .reply(200, []); + + it("returns prs that is going to be released", function (done) { + const client = new GithubClient({ + owner: "uiureo", + repo: "awesome-app", + head: "org:branch", + }); + client + .collectReleasePRs({ number: 42 }) + .then(function (prs) { + assert(prs.length === 0); + done(); + }) + .catch(done); + }); + }); + describe("#assignReviewers()", function () { const USER1 = "pr1-owner"; const USER2 = "pr2-owner";