From 6d7895db3a5803f0a7690110b0cb784da0fe3d38 Mon Sep 17 00:00:00 2001 From: James Ives Date: Wed, 8 Jan 2020 08:32:47 -0500 Subject: [PATCH] [Issue-111] Deployment Hotfix (#113) * hotfix-1 * f * Unit test fixes * s * Change * lk * Update git.test.ts --- __tests__/git.test.ts | 6 +++--- lib/git.js | 4 ++-- src/git.ts | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts index 7e181aff..8590cae8 100644 --- a/__tests__/git.test.ts +++ b/__tests__/git.test.ts @@ -30,7 +30,7 @@ describe("git", () => { }); const call = await init(); - expect(execute).toBeCalledTimes(4); + expect(execute).toBeCalledTimes(3); expect(call).toBe("Initialization step complete..."); }); @@ -46,7 +46,7 @@ describe("git", () => { const call = await init(); - expect(execute).toBeCalledTimes(4); + expect(execute).toBeCalledTimes(3); expect(call).toBe("Initialization step complete..."); }); @@ -109,7 +109,7 @@ describe("git", () => { const call = await init(); - expect(execute).toBeCalledTimes(4); + expect(execute).toBeCalledTimes(3); expect(call).toBe("Initialization step complete..."); }); }); diff --git a/lib/git.js b/lib/git.js index a060e751..c78f0178 100644 --- a/lib/git.js +++ b/lib/git.js @@ -68,7 +68,7 @@ function generateBranch() { yield util_1.execute(`git reset --hard`, constants_1.workspace); yield util_1.execute(`git commit --allow-empty -m "Initial ${constants_1.action.branch} commit."`, constants_1.workspace); yield util_1.execute(`git push ${constants_1.repositoryPath} ${constants_1.action.branch}`, constants_1.workspace); - yield switchToBaseBranch(); + yield util_1.execute(`git fetch`, constants_1.workspace); } catch (error) { core.setFailed(`There was an error creating the deployment branch: ${error} ❌`); @@ -97,7 +97,7 @@ function deploy() { } // Checks out the base branch to begin the deployment process. yield switchToBaseBranch(); - yield util_1.execute(`git fetch origin`, constants_1.workspace); + yield util_1.execute(`git fetch ${constants_1.repositoryPath}`, constants_1.workspace); yield util_1.execute(`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${constants_1.action.branch}`, constants_1.workspace); // Ensures that items that need to be excluded from the clean job get parsed. let excludes = ""; diff --git a/src/git.ts b/src/git.ts index 7a2065fe..ae3ba639 100644 --- a/src/git.ts +++ b/src/git.ts @@ -22,7 +22,6 @@ export async function init(): Promise { await execute(`git init`, workspace); await execute(`git config user.name ${action.name}`, workspace); await execute(`git config user.email ${action.email}`, workspace); - await execute(`git fetch origin`, workspace); } catch (error) { core.setFailed(`There was an error initializing the repository: ${error}`); } finally { @@ -58,7 +57,7 @@ export async function generateBranch(): Promise { workspace ); await execute(`git push ${repositoryPath} ${action.branch}`, workspace); - await switchToBaseBranch(); + await execute(`git fetch`, workspace); } catch (error) { core.setFailed( `There was an error creating the deployment branch: ${error} ❌` @@ -89,7 +88,7 @@ export async function deploy(): Promise { // Checks out the base branch to begin the deployment process. await switchToBaseBranch(); - await execute(`git fetch origin`, workspace); + await execute(`git fetch ${repositoryPath}`, workspace); await execute( `git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`, workspace