diff --git a/scripts/open-cherry-pick-pr.ts b/scripts/open-cherry-pick-pr.ts index 8d8916d4294..2bad1438d31 100644 --- a/scripts/open-cherry-pick-pr.ts +++ b/scripts/open-cherry-pick-pr.ts @@ -24,14 +24,17 @@ async function main() { ]); const currentAuthor = runSequence([ ["git", ["log", "-1", `--pretty="%aN <%aE>"`]] - ]) + ]); + runSequence([ + ["git", ["fetch", "origin", "master"]] + ]); let logText = runSequence([ - ["git", ["log", `master..${currentSha}`, `--pretty="%h %s%n%b"`]] + ["git", ["log", `origin/master..${currentSha.trim()}`, `--pretty="%h %s%n%b"`]] ]); logText = `Cherry-pick PR #${process.env.SOURCE_ISSUE} into ${process.env.TARGET_BRANCH} Component commits: -${logText}` +${logText.trim()}` const logpath = path.join(__dirname, "../", "logmessage.txt"); runSequence([ ["git", ["checkout", "-b", "temp-branch"]], @@ -39,7 +42,7 @@ ${logText}` ]); fs.writeFileSync(logpath, logText); runSequence([ - ["git", ["commit", "-F", logpath, `--author="${currentAuthor}"`]] + ["git", ["commit", "-F", logpath, `--author="${currentAuthor.trim()}"`]] ]); fs.unlinkSync(logpath); const squashSha = runSequence([ @@ -48,7 +51,7 @@ ${logText}` runSequence([ ["git", ["checkout", process.env.TARGET_BRANCH]], // checkout the target branch ["git", ["checkout", "-b", branchName]], // create a new branch - ["git", ["cherry-pick", squashSha]], // + ["git", ["cherry-pick", squashSha.trim()]], // ["git", ["remote", "add", "fork", remoteUrl]], // Add the remote fork ["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch ]);