From 91f72e309ed2ad06c50d8daae52cd7b7595630b4 Mon Sep 17 00:00:00 2001 From: James Ives Date: Sun, 29 Sep 2024 15:45:00 +0000 Subject: [PATCH] =?UTF-8?q?Deploy=20Production=20Code=20for=20Commit=2077b?= =?UTF-8?q?5e666121b2aa90cd82b593a978636cd94833d=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/worktree.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/worktree.js b/lib/worktree.js index 4e44b528a..5b963f68c 100644 --- a/lib/worktree.js +++ b/lib/worktree.js @@ -80,8 +80,15 @@ function generateWorktree(action, worktreedir, branchExists) { catch (error) { (0, core_1.info)('Error encountered while checking out branch. Attempting to continue with a new branch name.'); branchName = `temp-${Date.now()}`; - checkout = new GitCheckout(branchName); - yield (0, execute_1.execute)(checkout.toString(), `${action.workspace}/${worktreedir}`, action.silent); + try { + checkout = new GitCheckout(branchName, `origin/${action.branch}`); + yield (0, execute_1.execute)(checkout.toString(), `${action.workspace}/${worktreedir}`, action.silent); + } + catch (error) { + (0, core_1.info)('Unable to track the origin branch…'); + checkout = new GitCheckout(branchName); + yield (0, execute_1.execute)(checkout.toString(), `${action.workspace}/${worktreedir}`, action.silent); + } } if (!branchExists) { (0, core_1.info)(`Created the ${branchName} branch… 🔧`); @@ -91,15 +98,15 @@ function generateWorktree(action, worktreedir, branchExists) { // New history isn't singleCommit, create empty initial commit yield (0, execute_1.execute)(`git commit --no-verify --allow-empty -m "Initial ${branchName} commit"`, `${action.workspace}/${worktreedir}`, action.silent); } - /** - * Ensure that the workspace is a safe directory. - */ - try { - yield (0, execute_1.execute)(`git config --global --add safe.directory "${action.workspace}/${worktreedir}"`, action.workspace, action.silent); - } - catch (_a) { - (0, core_1.info)('Unable to set worktree temp directory as a safe directory…'); - } + } + /** + * Ensure that the workspace is a safe directory. + */ + try { + yield (0, execute_1.execute)(`git config --global --add safe.directory "${action.workspace}/${worktreedir}"`, action.workspace, action.silent); + } + catch (_a) { + (0, core_1.info)('Unable to set worktree temp directory as a safe directory…'); } } catch (error) {