Strictify the cherry-pick pr script

This commit is contained in:
Wesley Wigham 2019-05-31 14:12:45 -07:00
parent cb2df757d7
commit 9a2957717e
No known key found for this signature in database
GPG key ID: D59F87F60C5400C9
2 changed files with 21 additions and 12 deletions

1
.gitignore vendored
View file

@ -44,6 +44,7 @@ scripts/ior.js
scripts/authors.js scripts/authors.js
scripts/configurePrerelease.js scripts/configurePrerelease.js
scripts/open-user-pr.js scripts/open-user-pr.js
scripts/open-cherry-pick-pr.js
scripts/processDiagnosticMessages.d.ts scripts/processDiagnosticMessages.d.ts
scripts/processDiagnosticMessages.js scripts/processDiagnosticMessages.js
scripts/produceLKG.js scripts/produceLKG.js

View file

@ -3,7 +3,7 @@
/// <reference types="node" /> /// <reference types="node" />
import Octokit = require("@octokit/rest"); import Octokit = require("@octokit/rest");
import {runSequence} from "./run-sequence"; const {runSequence} = require("./run-sequence");
import fs = require("fs"); import fs = require("fs");
import path = require("path"); 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`; const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`;
async function main() { 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([ const currentSha = runSequence([
["git", ["rev-parse", "HEAD"]] ["git", ["rev-parse", "HEAD"]]
]); ]);
@ -80,15 +86,17 @@ ${logText}`
main().catch(async e => { main().catch(async e => {
console.error(e); console.error(e);
process.exitCode = 1; process.exitCode = 1;
const gh = new Octokit(); if (process.env.SOURCE_ISSUE) {
gh.authenticate({ const gh = new Octokit();
type: "token", gh.authenticate({
token: process.argv[2] type: "token",
}); token: process.argv[2]
await gh.issues.createComment({ });
number: +process.env.SOURCE_ISSUE, await gh.issues.createComment({
owner: "Microsoft", number: +process.env.SOURCE_ISSUE,
repo: "TypeScript", owner: "Microsoft",
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.` 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.`
});
}
}); });