From f6689283edf5028a7b64e80261b96df183307bc9 Mon Sep 17 00:00:00 2001 From: Yuxuan Jiang Date: Tue, 25 Jun 2024 15:01:32 +0800 Subject: [PATCH] branch already exist handling --- eng/copilot/testTranslation.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eng/copilot/testTranslation.js b/eng/copilot/testTranslation.js index deefda6b6..71def245f 100644 --- a/eng/copilot/testTranslation.js +++ b/eng/copilot/testTranslation.js @@ -48,7 +48,7 @@ async function syncPrChange() { //prepare for github commit const sha = await getLatestCommitSha(targetRepoOwner, targetRepo); - const changeSha = await createChangeBranch(targetRepoOwner, targetRepo, sha); + let changeSha = await createChangeBranch(targetRepoOwner, targetRepo, sha); //stash files -> commit -> push const blobs = await createBlob(targetRepoOwner, targetRepo, translatedFiles); @@ -57,7 +57,11 @@ async function syncPrChange() { await updateBranch(targetRepoOwner, targetRepo, commitSha); //create pr - // await createPR(targetRepoOwner, targetRepo); + if (changeSha === sha) { + console.log("Branch already exists. Skipping PR creation."); + } else { + await createPR(targetRepoOwner, targetRepo); + } } async function translate(file, sessionId, accessToken, targetLanguage) {