Skip to content

Commit f84c57f

Browse files
author
Orta Therox
authored
Merge pull request #25 from microsoft/no-response-to-bot
Typescript-bot shouldnt reply to a PR it opened
2 parents d0c0c19 + 68749c2 commit f84c57f

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

src/anyRepoHandlePullRequest.ts

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const generatePRInfo = async (api: Octokit, payload: WebhookPayloadPullRequest,
6464
return {
6565
thisIssue,
6666
authorIsMemberOfTSTeam,
67+
authorIsTypescriptBot: payload.pull_request.user.login === "typescript-bot",
6768
relatedIssues,
6869
comments
6970
}

src/checks/addCommentToUncommittedPRs.test.ts

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ describe(addCommentToUncommittedPRs, () => {
2525
expect(mockAPI.issues.removeLabel).not.toHaveBeenCalled()
2626
})
2727

28+
it("does not adds a comment to an uncommented, unlinked PR posted by typescript-bot", async () => {
29+
const { mockAPI, api } = createMockGitHubClient()
30+
mockAPI.issues.listComments.mockResolvedValue({ data: [] })
31+
const pr = getPRFixture("opened")
32+
pr.pull_request.user.login = "typescript-bot"
33+
34+
const info = createPRInfo({ authorIsTypescriptBot: true })
35+
await addCommentToUncommittedPRs(api, pr, getFakeLogger(), info)
36+
37+
expect(mockAPI.issues.createComment).not.toHaveBeenCalled()
38+
})
39+
2840
it("Adds a comment to an uncommented PR linked to uncommitted suggestion", async () => {
2941
const { mockAPI, api } = createMockGitHubClient()
3042

src/checks/addCommentToUncommittedPRs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { PRInfo } from "../anyRepoHandlePullRequest"
77
* Comment on new PRs that don't have linked issues, or link to uncommitted issues.
88
*/
99
export const addCommentToUncommittedPRs = async (api: Octokit, payload: WebhookPayloadPullRequest, logger: Logger, info: PRInfo) => {
10-
if (payload.pull_request.merged || payload.pull_request.draft || info.authorIsMemberOfTSTeam) {
10+
if (payload.pull_request.merged || payload.pull_request.draft || info.authorIsMemberOfTSTeam || info.authorIsTypescriptBot) {
1111
return logger("Skipping")
1212
}
1313

src/util/tests/createPRInfo.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const createPRInfo = (info?: Partial<PRInfo>): PRInfo => {
44
return {
55
comments: [],
66
authorIsMemberOfTSTeam: false,
7+
authorIsTypescriptBot: false,
78
relatedIssues: [],
89
thisIssue: {
910
issue_number: 35454,

0 commit comments

Comments
 (0)