mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-23 10:29:01 -06:00
Also edit the cherry-pick script to handle non-master base branches while we are here
This commit is contained in:
parent
a8f01dfff8
commit
8ef498f69e
@ -26,18 +26,34 @@ async function main() {
|
||||
const currentAuthor = runSequence([
|
||||
["git", ["log", "-1", `--pretty="%aN <%aE>"`]]
|
||||
]);
|
||||
|
||||
const gh = new Octokit();
|
||||
gh.authenticate({
|
||||
type: "token",
|
||||
token: process.argv[2]
|
||||
});
|
||||
|
||||
const inputPR = (await gh.pulls.get({ pull_number: +process.env.SOURCE_ISSUE, owner: "microsoft", repo: "TypeScript" })).data;
|
||||
let remoteName = "origin";
|
||||
if (inputPR.base.repo.git_url !== `git:github.com/microsoft/TypeScript`) {
|
||||
runSequence([
|
||||
["git", ["remote", "add", "nonlocal", inputPR.base.repo.git_url]]
|
||||
]);
|
||||
remoteName = "nonlocal";
|
||||
}
|
||||
const baseBranchName = inputPR.base.ref;
|
||||
runSequence([
|
||||
["git", ["fetch", "origin", "master"]]
|
||||
["git", ["fetch", remoteName, baseBranchName]]
|
||||
]);
|
||||
let logText = runSequence([
|
||||
["git", ["log", `origin/master..${currentSha.trim()}`, `--pretty="%h %s%n%b"`, "--reverse"]]
|
||||
["git", ["log", `${remoteName}/${baseBranchName}..${currentSha.trim()}`, `--pretty="%h %s%n%b"`, "--reverse"]]
|
||||
]);
|
||||
logText = `Cherry-pick PR #${process.env.SOURCE_ISSUE} into ${process.env.TARGET_BRANCH}
|
||||
|
||||
Component commits:
|
||||
${logText.trim()}`;
|
||||
const logpath = path.join(__dirname, "../", "logmessage.txt");
|
||||
const mergebase = runSequence([["git", ["merge-base", "origin/master", currentSha]]]).trim();
|
||||
const mergebase = runSequence([["git", ["merge-base", `${remoteName}/${baseBranchName}`, currentSha]]]).trim();
|
||||
runSequence([
|
||||
["git", ["checkout", "-b", "temp-branch"]],
|
||||
["git", ["reset", mergebase, "--soft"]]
|
||||
@ -67,11 +83,6 @@ ${logText.trim()}`;
|
||||
["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch
|
||||
]);
|
||||
|
||||
const gh = new Octokit();
|
||||
gh.authenticate({
|
||||
type: "token",
|
||||
token: process.argv[2]
|
||||
});
|
||||
const r = await gh.pulls.create({
|
||||
owner: "Microsoft",
|
||||
repo: "TypeScript",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user