Skip to content

Commit 73616c9

Browse files
committed
More conditional linkage in user PR responses when manually triggered
1 parent 0ddd847 commit 73616c9

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

scripts/open-user-pr.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ function padNum(number: number) {
1818
}
1919

2020
const userName = process.env.GH_USERNAME;
21-
const reviewers = ["weswigham", "sandersn", "RyanCavanaugh"]
21+
const reviewers = ["weswigham", "sandersn", "RyanCavanaugh"];
22+
if (process.env.requesting_user && reviewers.indexOf(process.env.requesting_user) === -1) {
23+
reviewers.push(process.env.requesting_user);
24+
}
2225
const now = new Date();
2326
const branchName = `user-update-${process.env.TARGET_FORK}-${now.getFullYear()}${padNum(now.getMonth())}${padNum(now.getDay())}${process.env.TARGET_BRANCH ? "-" + process.env.TARGET_BRANCH : ""}`;
2427
const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`;
@@ -41,23 +44,31 @@ gh.pulls.create({
4144
owner: process.env.TARGET_FORK,
4245
repo: "TypeScript",
4346
maintainer_can_modify: true,
44-
title: `🤖 User test baselines have changed`,
47+
title: `🤖 User test baselines have changed` + (process.env.TARGET_BRANCH ? ` for ${process.env.TARGET_BRANCH}` : ""),
4548
head: `${userName}:${branchName}`,
4649
base: process.env.TARGET_BRANCH || "master",
4750
body:
48-
`Please review the diff and merge if no changes are unexpected.
51+
`${process.env.source_issue ? `This test run was triggerd by a request on https://github.com/Microsoft/TypeScript/pull/${process.env.source_issue} `+"\n" : ""}Please review the diff and merge if no changes are unexpected.
4952
You can view the build log [here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary).
5053
5154
cc ${reviewers.map(r => "@" + r).join(" ")}`,
52-
}).then(r => {
55+
}).then(async r => {
5356
const num = r.data.number;
5457
console.log(`Pull request ${num} created.`);
55-
return gh.pulls.createReviewRequest({
58+
await gh.pulls.createReviewRequest({
5659
owner: process.env.TARGET_FORK,
5760
repo: "TypeScript",
5861
number: num,
5962
reviewers,
6063
});
64+
if (process.env.source_issue) {
65+
await gh.issues.createComment({
66+
number: +process.env.source_issue,
67+
owner: "Microsoft",
68+
repo: "TypeScript",
69+
body: `The user suite test run you requested has finished and _failed_. I've opened a [PR with the baseline diff from master](${r.data.html_url}).`
70+
});
71+
}
6172
}).then(() => {
6273
console.log(`Reviewers requested, done.`);
6374
}).catch(e => {

0 commit comments

Comments
 (0)