Skip to content

Commit 9a29577

Browse files
committed
Strictify the cherry-pick pr script
1 parent cb2df75 commit 9a29577

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ scripts/ior.js
4444
scripts/authors.js
4545
scripts/configurePrerelease.js
4646
scripts/open-user-pr.js
47+
scripts/open-cherry-pick-pr.js
4748
scripts/processDiagnosticMessages.d.ts
4849
scripts/processDiagnosticMessages.js
4950
scripts/produceLKG.js

scripts/open-cherry-pick-pr.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// <reference types="node" />
44

55
import Octokit = require("@octokit/rest");
6-
import {runSequence} from "./run-sequence";
6+
const {runSequence} = require("./run-sequence");
77
import fs = require("fs");
88
import path = require("path");
99

@@ -13,6 +13,12 @@ const branchName = `pick/${process.env.SOURCE_ISSUE}/${process.env.TARGET_BRANCH
1313
const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`;
1414

1515
async function main() {
16+
if (!process.env.TARGET_BRANCH) {
17+
throw new Error("Target branch not specified");
18+
}
19+
if (!process.env.SOURCE_ISSUE) {
20+
throw new Error("Source issue not specified");
21+
}
1622
const currentSha = runSequence([
1723
["git", ["rev-parse", "HEAD"]]
1824
]);
@@ -80,15 +86,17 @@ ${logText}`
8086
main().catch(async e => {
8187
console.error(e);
8288
process.exitCode = 1;
83-
const gh = new Octokit();
84-
gh.authenticate({
85-
type: "token",
86-
token: process.argv[2]
87-
});
88-
await gh.issues.createComment({
89-
number: +process.env.SOURCE_ISSUE,
90-
owner: "Microsoft",
91-
repo: "TypeScript",
92-
body: `Hey @${process.env.REQUESTING_USER}, I couldn't open a PR with the cherry-pick. ([You can check the log here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary)). You may need to squash and pick this PR into ${process.env.TARGET_BRANCH} manually.`
93-
});
89+
if (process.env.SOURCE_ISSUE) {
90+
const gh = new Octokit();
91+
gh.authenticate({
92+
type: "token",
93+
token: process.argv[2]
94+
});
95+
await gh.issues.createComment({
96+
number: +process.env.SOURCE_ISSUE,
97+
owner: "Microsoft",
98+
repo: "TypeScript",
99+
body: `Hey @${process.env.REQUESTING_USER}, I couldn't open a PR with the cherry-pick. ([You can check the log here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary)). You may need to squash and pick this PR into ${process.env.TARGET_BRANCH} manually.`
100+
});
101+
}
94102
});

0 commit comments

Comments
 (0)