From 36ec63f965a4db5aa3e3ce569fc03f3102f57451 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 14 Sep 2021 08:02:42 -0400 Subject: [PATCH] Improve `PingReviewersOther` Don't say that "you're the only owner" if the author is not an existing owner or a new one. --- src/_tests/fixtures/45946/mutations.json | 2 +- src/_tests/fixtures/45946/result.json | 2 +- src/_tests/fixtures/49575/mutations.json | 2 +- src/_tests/fixtures/49575/result.json | 2 +- src/_tests/fixtures/49841/mutations.json | 2 +- src/_tests/fixtures/49841/result.json | 2 +- src/_tests/fixtures/50429/mutations.json | 9 + src/_tests/fixtures/50429/result.json | 2 +- .../fixtures/52579-edits-infra/mutations.json | 9 + .../fixtures/52579-edits-infra/result.json | 2 +- src/_tests/fixtures/52848/mutations.json | 9 + src/_tests/fixtures/52848/result.json | 2 +- src/_tests/fixtures/55741/_downloads.json | 3 + src/_tests/fixtures/55741/_files.json | 5 + src/_tests/fixtures/55741/_response.json | 292 ++++++++++++++++++ src/_tests/fixtures/55741/derived.json | 46 +++ src/_tests/fixtures/55741/mutations.json | 20 ++ src/_tests/fixtures/55741/result.json | 19 ++ src/comments.ts | 5 +- src/compute-pr-actions.ts | 3 +- 20 files changed, 426 insertions(+), 12 deletions(-) create mode 100644 src/_tests/fixtures/55741/_downloads.json create mode 100644 src/_tests/fixtures/55741/_files.json create mode 100644 src/_tests/fixtures/55741/_response.json create mode 100644 src/_tests/fixtures/55741/derived.json create mode 100644 src/_tests/fixtures/55741/mutations.json create mode 100644 src/_tests/fixtures/55741/result.json diff --git a/src/_tests/fixtures/45946/mutations.json b/src/_tests/fixtures/45946/mutations.json index bff52432..408e88dd 100644 --- a/src/_tests/fixtures/45946/mutations.json +++ b/src/_tests/fixtures/45946/mutations.json @@ -33,7 +33,7 @@ "variables": { "input": { "subjectId": "MDExOlB1bGxSZXF1ZXN0NDQ2MDIxMjkw", - "body": "🔔 @rubensworks — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45946/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" + "body": "🔔 @rubensworks — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45946/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" } } } diff --git a/src/_tests/fixtures/45946/result.json b/src/_tests/fixtures/45946/result.json index 38cfa5a9..8e190b21 100644 --- a/src/_tests/fixtures/45946/result.json +++ b/src/_tests/fixtures/45946/result.json @@ -11,7 +11,7 @@ }, { "tag": "pinging-reviewers-others", - "status": "🔔 @rubensworks — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45946/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" + "status": "🔔 @rubensworks — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45946/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" } ], "shouldClose": false, diff --git a/src/_tests/fixtures/49575/mutations.json b/src/_tests/fixtures/49575/mutations.json index 7516a1ff..a2d17964 100644 --- a/src/_tests/fixtures/49575/mutations.json +++ b/src/_tests/fixtures/49575/mutations.json @@ -35,7 +35,7 @@ "variables": { "input": { "subjectId": "MDExOlB1bGxSZXF1ZXN0NTIxMTM3NjEy", - "body": "🔔 @jablko — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49575/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" + "body": "🔔 @jablko — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49575/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" } } }, diff --git a/src/_tests/fixtures/49575/result.json b/src/_tests/fixtures/49575/result.json index b922bc25..a7eed0b5 100644 --- a/src/_tests/fixtures/49575/result.json +++ b/src/_tests/fixtures/49575/result.json @@ -11,7 +11,7 @@ }, { "tag": "pinging-reviewers-others", - "status": "🔔 @jablko — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49575/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" + "status": "🔔 @jablko — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49575/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" }, { "tag": "stale-ping-d2e897-6400f4c", diff --git a/src/_tests/fixtures/49841/mutations.json b/src/_tests/fixtures/49841/mutations.json index 7e0da225..1fce78c8 100644 --- a/src/_tests/fixtures/49841/mutations.json +++ b/src/_tests/fixtures/49841/mutations.json @@ -45,7 +45,7 @@ "variables": { "input": { "subjectId": "MDExOlB1bGxSZXF1ZXN0NTI4OTE2Mjg5", - "body": "🔔 @shekari-ah — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49841/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" + "body": "🔔 @shekari-ah — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49841/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" } } }, diff --git a/src/_tests/fixtures/49841/result.json b/src/_tests/fixtures/49841/result.json index 4cdd9e35..4f92c5cb 100644 --- a/src/_tests/fixtures/49841/result.json +++ b/src/_tests/fixtures/49841/result.json @@ -11,7 +11,7 @@ }, { "tag": "pinging-reviewers-others", - "status": "🔔 @shekari-ah — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49841/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" + "status": "🔔 @shekari-ah — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/49841/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" }, { "tag": "gh-actions-complaint-4849e88", diff --git a/src/_tests/fixtures/50429/mutations.json b/src/_tests/fixtures/50429/mutations.json index 49f94e25..c239ee49 100644 --- a/src/_tests/fixtures/50429/mutations.json +++ b/src/_tests/fixtures/50429/mutations.json @@ -28,6 +28,15 @@ } } }, + { + "mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "id": "MDEyOklzc3VlQ29tbWVudDc1NTI4NDk4Mg==", + "body": "🔔 @SaltyAom — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50429/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" + } + } + }, { "mutation": "mutation ($input: AddCommentInput!) {\n addComment(input: $input) {\n __typename\n }\n}\n", "variables": { diff --git a/src/_tests/fixtures/50429/result.json b/src/_tests/fixtures/50429/result.json index d9c425bb..d9067c97 100644 --- a/src/_tests/fixtures/50429/result.json +++ b/src/_tests/fixtures/50429/result.json @@ -12,7 +12,7 @@ }, { "tag": "pinging-reviewers-others", - "status": "🔔 @SaltyAom — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50429/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" + "status": "🔔 @SaltyAom — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50429/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" }, { "tag": "gh-actions-complaint-8454d08", diff --git a/src/_tests/fixtures/52579-edits-infra/mutations.json b/src/_tests/fixtures/52579-edits-infra/mutations.json index cbc502e5..1e51ae26 100644 --- a/src/_tests/fixtures/52579-edits-infra/mutations.json +++ b/src/_tests/fixtures/52579-edits-infra/mutations.json @@ -19,5 +19,14 @@ "labelableId": "MDExOlB1bGxSZXF1ZXN0NjIyODUxNTk2" } } + }, + { + "mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "id": "MDEyOklzc3VlQ29tbWVudDgyNjM5OTk3MA==", + "body": "🔔 @Phong6698 — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52579/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" + } + } } ] diff --git a/src/_tests/fixtures/52579-edits-infra/result.json b/src/_tests/fixtures/52579-edits-infra/result.json index fa2aeb38..48d6d701 100644 --- a/src/_tests/fixtures/52579-edits-infra/result.json +++ b/src/_tests/fixtures/52579-edits-infra/result.json @@ -12,7 +12,7 @@ }, { "tag": "pinging-reviewers-others", - "status": "🔔 @Phong6698 — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52579/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" + "status": "🔔 @Phong6698 — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52579/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" } ], "shouldClose": false, diff --git a/src/_tests/fixtures/52848/mutations.json b/src/_tests/fixtures/52848/mutations.json index 4a35c53a..354e2608 100644 --- a/src/_tests/fixtures/52848/mutations.json +++ b/src/_tests/fixtures/52848/mutations.json @@ -28,6 +28,15 @@ } } }, + { + "mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "id": "MDEyOklzc3VlQ29tbWVudDgzNjMyOTAwMg==", + "body": "🔔 @Runtu4378 — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" + } + } + }, { "mutation": "mutation ($input: AddCommentInput!) {\n addComment(input: $input) {\n __typename\n }\n}\n", "variables": { diff --git a/src/_tests/fixtures/52848/result.json b/src/_tests/fixtures/52848/result.json index 7a53307e..1ae5bfc8 100644 --- a/src/_tests/fixtures/52848/result.json +++ b/src/_tests/fixtures/52848/result.json @@ -11,7 +11,7 @@ }, { "tag": "pinging-reviewers-others", - "status": "🔔 @Runtu4378 — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" + "status": "🔔 @Runtu4378 — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/52848/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" }, { "tag": "merge-offer", diff --git a/src/_tests/fixtures/55741/_downloads.json b/src/_tests/fixtures/55741/_downloads.json new file mode 100644 index 00000000..52321ec9 --- /dev/null +++ b/src/_tests/fixtures/55741/_downloads.json @@ -0,0 +1,3 @@ +{ + "ax": 0 +} diff --git a/src/_tests/fixtures/55741/_files.json b/src/_tests/fixtures/55741/_files.json new file mode 100644 index 00000000..bc9c19ca --- /dev/null +++ b/src/_tests/fixtures/55741/_files.json @@ -0,0 +1,5 @@ +{ + "aded751196aea4180928204085f088eb530d7b88:types/ax/tsconfig.json": "{\n \"compilerOptions\": {\n \"module\": \"commonjs\",\n \"lib\": [\n \"es6\"\n ],\n \"noImplicitAny\": true,\n \"noImplicitThis\": true,\n \"strictFunctionTypes\": true,\n \"strictNullChecks\": true,\n \"baseUrl\": \"../\",\n \"typeRoots\": [\n \"../\"\n ],\n \"types\": [],\n \"noEmit\": true,\n \"forceConsistentCasingInFileNames\": true\n },\n \"files\": [\n \"index.d.ts\",\n \"ax-tests.ts\"\n ]\n}\n", + "aded751196aea4180928204085f088eb530d7b88:types/ax/tslint.json": "{ \"extends\": \"dtslint/dt.json\" }\n", + "aded751196aea4180928204085f088eb530d7b88:types/ax/index.d.ts": "// Type definitions for ax 0.1\n// Project: https://github.com/AstroxNetwork/ax\n// Definitions by: Hsehoiki \n// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\n\ninterface AxType {\n /**\n * ax function\n */\n setNavigationBarTitle: (text: string) => boolean;\n setNavigationBarColor: (color: string) => boolean;\n}\n\n/**\n * ax is global object\n */\ndeclare const ax: AxType;\n\nexport = ax;\n" +} diff --git a/src/_tests/fixtures/55741/_response.json b/src/_tests/fixtures/55741/_response.json new file mode 100644 index 00000000..ebc0ddd3 --- /dev/null +++ b/src/_tests/fixtures/55741/_response.json @@ -0,0 +1,292 @@ +{ + "data": { + "repository": { + "id": "MDEwOlJlcG9zaXRvcnk2MDkzMzE2", + "pullRequest": { + "id": "MDExOlB1bGxSZXF1ZXN0NzMyNTEwMzkx", + "title": "Feat/kasumisk", + "createdAt": "2021-09-13T08:32:21Z", + "author": { + "login": "kasumisk", + "__typename": "User" + }, + "authorAssociation": "FIRST_TIME_CONTRIBUTOR", + "baseRef": { + "name": "master", + "__typename": "Ref" + }, + "labels": { + "nodes": [ + { + "name": "New Definition", + "__typename": "Label" + } + ], + "__typename": "LabelConnection" + }, + "isDraft": false, + "mergeable": "MERGEABLE", + "number": 55741, + "state": "OPEN", + "headRefOid": "aded751196aea4180928204085f088eb530d7b88", + "changedFiles": 4, + "timelineItems": { + "nodes": [ + { + "actor": { + "login": "typescript-bot", + "__typename": "User" + }, + "createdAt": "2021-09-13T08:40:11Z", + "projectColumnName": "Waiting for Code Reviews", + "__typename": "MovedColumnsInProjectEvent" + }, + { + "createdAt": "2021-09-13T08:41:20Z", + "__typename": "ReopenedEvent" + }, + { + "actor": { + "login": "typescript-bot", + "__typename": "User" + }, + "createdAt": "2021-09-13T08:44:47Z", + "projectColumnName": "Needs Maintainer Action", + "__typename": "MovedColumnsInProjectEvent" + } + ], + "__typename": "PullRequestTimelineItemsConnection" + }, + "reviews": { + "nodes": [], + "__typename": "PullRequestReviewConnection" + }, + "commits": { + "totalCount": 3, + "nodes": [ + { + "commit": { + "checkSuites": { + "nodes": [ + { + "databaseId": 3751060170, + "app": { + "name": "GitHub Actions", + "__typename": "App" + }, + "conclusion": "SUCCESS", + "resourcePath": "/DefinitelyTyped/DefinitelyTyped/commit/aded751196aea4180928204085f088eb530d7b88/checks?check_suite_id=3751060170", + "status": "COMPLETED", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/aded751196aea4180928204085f088eb530d7b88/checks?check_suite_id=3751060170", + "checkRuns": { + "nodes": [ + { + "title": null, + "__typename": "CheckRun" + } + ], + "__typename": "CheckRunConnection" + }, + "__typename": "CheckSuite" + }, + { + "databaseId": 3751061670, + "app": { + "name": "Azure Pipelines", + "__typename": "App" + }, + "conclusion": "SUCCESS", + "resourcePath": "/DefinitelyTyped/DefinitelyTyped/commit/aded751196aea4180928204085f088eb530d7b88/checks?check_suite_id=3751061670", + "status": "COMPLETED", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/aded751196aea4180928204085f088eb530d7b88/checks?check_suite_id=3751061670", + "checkRuns": { + "nodes": [ + { + "title": "Build #20210913.8 succeeded", + "__typename": "CheckRun" + } + ], + "__typename": "CheckRunConnection" + }, + "__typename": "CheckSuite" + }, + { + "databaseId": 3751075506, + "app": { + "name": "GitHub Actions", + "__typename": "App" + }, + "conclusion": "SUCCESS", + "resourcePath": "/DefinitelyTyped/DefinitelyTyped/commit/aded751196aea4180928204085f088eb530d7b88/checks?check_suite_id=3751075506", + "status": "COMPLETED", + "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/commit/aded751196aea4180928204085f088eb530d7b88/checks?check_suite_id=3751075506", + "checkRuns": { + "nodes": [ + { + "title": null, + "__typename": "CheckRun" + } + ], + "__typename": "CheckRunConnection" + }, + "__typename": "CheckSuite" + } + ], + "__typename": "CheckSuiteConnection" + }, + "status": null, + "authoredDate": "2021-09-13T08:39:27Z", + "committedDate": "2021-09-13T08:39:27Z", + "pushedDate": "2021-09-13T08:39:37Z", + "oid": "aded751196aea4180928204085f088eb530d7b88", + "__typename": "Commit" + }, + "__typename": "PullRequestCommit" + } + ], + "__typename": "PullRequestCommitConnection" + }, + "comments": { + "totalCount": 5, + "nodes": [ + { + "id": "IC_kwDOAFz6BM42twsQ", + "author": { + "login": "typescript-bot", + "__typename": "User" + }, + "databaseId": 917965584, + "body": "@kasumisk Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.\n\n***This is a live comment which I will keep updated.***\n\n## 1 package in this PR\n\n* `ax` (*new!*) — [on npm](https://www.npmjs.com/package/ax), [on unpkg](https://unpkg.com/browse/ax@latest/)\n - 1 added owner: @AstroxNetwork\n\n## Code Reviews\n\nThis PR adds a new definition, so it needs to be reviewed by a DT maintainer before it can be merged.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=55741&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 Only a DT maintainer can approve changes when there are new packages added\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n", + "createdAt": "2021-09-13T08:34:30Z", + "reactions": { + "nodes": [], + "__typename": "ReactionConnection" + }, + "__typename": "IssueComment" + }, + { + "id": "IC_kwDOAFz6BM42twsu", + "author": { + "login": "typescript-bot", + "__typename": "User" + }, + "databaseId": 917965614, + "body": "🔔 @kasumisk — you're the only owner, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55741/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n", + "createdAt": "2021-09-13T08:34:32Z", + "reactions": { + "nodes": [], + "__typename": "ReactionConnection" + }, + "__typename": "IssueComment" + }, + { + "id": "IC_kwDOAFz6BM42tws1", + "author": { + "login": "typescript-bot", + "__typename": "User" + }, + "databaseId": 917965621, + "body": "@kasumisk The CI build failed! Please [review the logs for more information](https://github.com/DefinitelyTyped/DefinitelyTyped/commit/f37f01fdf29022d7f5bf05988adc1fb28f84db9d/checks?check_suite_id=3750996288).\n\nOnce you've pushed the fixes, the build will automatically re-run. Thanks!\n\n**Note: builds which are failing do not end up on the list of PRs for the DT maintainers to review.**\n", + "createdAt": "2021-09-13T08:34:33Z", + "reactions": { + "nodes": [], + "__typename": "ReactionConnection" + }, + "__typename": "IssueComment" + }, + { + "id": "IC_kwDOAFz6BM42txtB", + "author": { + "login": "kasumisk", + "__typename": "User" + }, + "databaseId": 917969729, + "body": "add ax", + "createdAt": "2021-09-13T08:40:13Z", + "reactions": { + "nodes": [], + "__typename": "ReactionConnection" + }, + "__typename": "IssueComment" + }, + { + "id": "IC_kwDOAFz6BM42wAqN", + "author": { + "login": "peterblazejewicz", + "__typename": "User" + }, + "databaseId": 918555277, + "body": "what's the relation to this declaration:\r\nhttps://github.com/AstroxNetwork/ax/blob/master/index.d.ts\r\nhttps://github.com/AstroxNetwork/ax/blob/master/package.json#L6", + "createdAt": "2021-09-13T20:35:23Z", + "reactions": { + "nodes": [], + "__typename": "ReactionConnection" + }, + "__typename": "IssueComment" + } + ], + "__typename": "IssueCommentConnection" + }, + "files": { + "totalCount": 4, + "nodes": [ + { + "path": "types/ax/ax-tests.ts", + "additions": 4, + "deletions": 0, + "__typename": "PullRequestChangedFile" + }, + { + "path": "types/ax/index.d.ts", + "additions": 19, + "deletions": 0, + "__typename": "PullRequestChangedFile" + }, + { + "path": "types/ax/tsconfig.json", + "additions": 23, + "deletions": 0, + "__typename": "PullRequestChangedFile" + }, + { + "path": "types/ax/tslint.json", + "additions": 1, + "deletions": 0, + "__typename": "PullRequestChangedFile" + } + ], + "pageInfo": { + "hasNextPage": false, + "endCursor": "NA", + "__typename": "PageInfo" + }, + "__typename": "PullRequestChangedFileConnection" + }, + "projectCards": { + "nodes": [ + { + "id": "PRC_lALOAFz6BM4AORWwzgQXZbg", + "project": { + "id": "MDc6UHJvamVjdDM3NDExMDQ=", + "number": 5, + "name": "New Pull Request Status Board", + "__typename": "Project" + }, + "column": { + "id": "MDEzOlByb2plY3RDb2x1bW45ODY3MDA2", + "name": "Needs Maintainer Action", + "__typename": "ProjectColumn" + }, + "__typename": "ProjectCard" + } + ], + "__typename": "ProjectCardConnection" + }, + "__typename": "PullRequest" + }, + "__typename": "Repository" + } + }, + "loading": false, + "networkStatus": 7 +} diff --git a/src/_tests/fixtures/55741/derived.json b/src/_tests/fixtures/55741/derived.json new file mode 100644 index 00000000..0ed54a65 --- /dev/null +++ b/src/_tests/fixtures/55741/derived.json @@ -0,0 +1,46 @@ +{ + "type": "info", + "now": "2021-09-14T10:47:18.683Z", + "pr_number": 55741, + "author": "kasumisk", + "headCommitOid": "aded751196aea4180928204085f088eb530d7b88", + "lastPushDate": "2021-09-13T08:39:37.000Z", + "lastActivityDate": "2021-09-13T20:35:23.000Z", + "hasMergeConflict": false, + "isFirstContribution": true, + "tooManyFiles": false, + "popularityLevel": "Well-liked by everyone", + "pkgInfo": [ + { + "name": "ax", + "kind": "add", + "files": [ + { + "path": "types/ax/ax-tests.ts", + "kind": "test" + }, + { + "path": "types/ax/index.d.ts", + "kind": "definition" + }, + { + "path": "types/ax/tsconfig.json", + "kind": "package-meta-ok" + }, + { + "path": "types/ax/tslint.json", + "kind": "package-meta-ok" + } + ], + "owners": [], + "addedOwners": [ + "AstroxNetwork" + ], + "deletedOwners": [], + "popularityLevel": "Well-liked by everyone" + } + ], + "reviews": [], + "mainBotCommentID": 917965584, + "ciResult": "pass" +} diff --git a/src/_tests/fixtures/55741/mutations.json b/src/_tests/fixtures/55741/mutations.json new file mode 100644 index 00000000..82745df1 --- /dev/null +++ b/src/_tests/fixtures/55741/mutations.json @@ -0,0 +1,20 @@ +[ + { + "mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "id": "IC_kwDOAFz6BM42twsQ", + "body": "@kasumisk Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.\n\n***This is a live comment which I will keep updated.***\n\n## 1 package in this PR\n\n* `ax` (*new!*) — [on npm](https://www.npmjs.com/package/ax), [on unpkg](https://unpkg.com/browse/ax@latest/)\n - 1 added owner: @AstroxNetwork\n\n## Code Reviews\n\nThis PR adds a new definition, so it needs to be reviewed by a DT maintainer before it can be merged.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=55741&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 Only a DT maintainer can approve changes when there are new packages added\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ...\n" + } + } + }, + { + "mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n", + "variables": { + "input": { + "id": "IC_kwDOAFz6BM42twsu", + "body": "🔔 @kasumisk — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55741/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)\n" + } + } + } +] diff --git a/src/_tests/fixtures/55741/result.json b/src/_tests/fixtures/55741/result.json new file mode 100644 index 00000000..57b530cb --- /dev/null +++ b/src/_tests/fixtures/55741/result.json @@ -0,0 +1,19 @@ +{ + "projectColumn": "Needs Maintainer Action", + "labels": [ + "New Definition" + ], + "responseComments": [ + { + "tag": "welcome", + "status": "@kasumisk Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.\n\n***This is a live comment which I will keep updated.***\n\n## 1 package in this PR\n\n* `ax` (*new!*) — [on npm](https://www.npmjs.com/package/ax), [on unpkg](https://unpkg.com/browse/ax@latest/)\n - 1 added owner: @AstroxNetwork\n\n## Code Reviews\n\nThis PR adds a new definition, so it needs to be reviewed by a DT maintainer before it can be merged.\n\nYou can test the changes of this PR [in the Playground](https://www.typescriptlang.org/play/?dtPR=55741&install-plugin=playground-dt-review).\n\n## Status\n\n * ✅ No merge conflicts\n * ✅ Continuous integration tests have passed\n * 🕐 Only a DT maintainer can approve changes when there are new packages added\n\nOnce every item on this list is checked, I'll ask you for permission to merge and publish the changes.\n\n----------------------\n... diagnostics scrubbed ..." + }, + { + "tag": "pinging-reviewers-others", + "status": "🔔 @kasumisk — there are no owners, but it would still be good if you find someone to [review this PR](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/55741/files) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)" + } + ], + "shouldClose": false, + "shouldMerge": false, + "shouldUpdateLabels": true +} diff --git a/src/comments.ts b/src/comments.ts index 7959c80e..b75a5ee0 100644 --- a/src/comments.ts +++ b/src/comments.ts @@ -65,10 +65,11 @@ export const PingReviewers = (names: readonly string[], reviewLink: string) => ( in the GitHub UI so I know what's going on.` }); -export const PingReviewersOther = (user: string, reviewLink: string) => ({ +export const PingReviewersOther = (user: string, authorIsOwner: boolean, reviewLink: string) => ({ tag: "pinging-reviewers-others", status: txt` - |🔔 @${user} — you're the only owner, but it would still be good if you find someone to + |🔔 @${user} — ${authorIsOwner ? "you're the only owner" : "there are no owners"}, + but it would still be good if you find someone to [review this PR](${reviewLink}) in the next few days, otherwise a maintainer will look at it. (And if you do find someone, maybe even recruit them to be a second owner to make future changes easier...)` diff --git a/src/compute-pr-actions.ts b/src/compute-pr-actions.ts index bc10d953..38c6f562 100644 --- a/src/compute-pr-actions.ts +++ b/src/compute-pr-actions.ts @@ -262,7 +262,8 @@ export function process(prInfo: BotResult, if (!(info.hasChangereqs || info.approvedBy.includes("owner") || info.approvedBy.includes("maintainer"))) { if (info.noOtherOwners) { if (info.popularityLevel !== "Critical") { - post(Comments.PingReviewersOther(info.author, urls.review(info.pr_number))); + const authorIsNewOwner = flatten(info.pkgInfo.map(p => p.addedOwners)).includes(info.author); + post(Comments.PingReviewersOther(info.author, info.authorIsOwner || authorIsNewOwner, urls.review(info.pr_number))); } } else if (info.tooManyOwners) { post(Comments.PingReviewersTooMany(info.otherOwners));