diff --git a/.gitignore b/.gitignore index 9d0bb4d0c6..04c397bb7e 100644 --- a/.gitignore +++ b/.gitignore @@ -44,6 +44,7 @@ scripts/ior.js scripts/authors.js scripts/configurePrerelease.js scripts/open-user-pr.js +scripts/open-cherry-pick-pr.js scripts/processDiagnosticMessages.d.ts scripts/processDiagnosticMessages.js scripts/produceLKG.js diff --git a/scripts/open-cherry-pick-pr.ts b/scripts/open-cherry-pick-pr.ts index 0d8109bafe..8d8916d429 100644 --- a/scripts/open-cherry-pick-pr.ts +++ b/scripts/open-cherry-pick-pr.ts @@ -3,7 +3,7 @@ /// import Octokit = require("@octokit/rest"); -import {runSequence} from "./run-sequence"; +const {runSequence} = require("./run-sequence"); import fs = require("fs"); import path = require("path"); @@ -13,6 +13,12 @@ const branchName = `pick/${process.env.SOURCE_ISSUE}/${process.env.TARGET_BRANCH const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`; async function main() { + if (!process.env.TARGET_BRANCH) { + throw new Error("Target branch not specified"); + } + if (!process.env.SOURCE_ISSUE) { + throw new Error("Source issue not specified"); + } const currentSha = runSequence([ ["git", ["rev-parse", "HEAD"]] ]); @@ -80,15 +86,17 @@ ${logText}` main().catch(async e => { console.error(e); process.exitCode = 1; - const gh = new Octokit(); - gh.authenticate({ - type: "token", - token: process.argv[2] - }); - await gh.issues.createComment({ - number: +process.env.SOURCE_ISSUE, - owner: "Microsoft", - repo: "TypeScript", - 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.` - }); + if (process.env.SOURCE_ISSUE) { + const gh = new Octokit(); + gh.authenticate({ + type: "token", + token: process.argv[2] + }); + await gh.issues.createComment({ + number: +process.env.SOURCE_ISSUE, + owner: "Microsoft", + repo: "TypeScript", + 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.` + }); + } }); \ No newline at end of file