From 0657078fb0411b8b183ddf639506b1cb27cb0dc2 Mon Sep 17 00:00:00 2001 From: James Ives Date: Sun, 24 May 2020 10:57:49 -0400 Subject: [PATCH] Removes the worktree (#309) * Removes the worktree * Tests --- __tests__/git.test.ts | 14 +++++++------- __tests__/main.test.ts | 4 ++-- src/git.ts | 4 ++++ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts index 127efcba..6063853f 100644 --- a/__tests__/git.test.ts +++ b/__tests__/git.test.ts @@ -341,7 +341,7 @@ describe('git', () => { const response = await deploy(action) // Includes the call to generateBranch - expect(execute).toBeCalledTimes(11) + expect(execute).toBeCalledTimes(12) expect(rmRF).toBeCalledTimes(1) expect(response).toBe(Status.SUCCESS) }) @@ -361,7 +361,7 @@ describe('git', () => { await deploy(action) // Includes the call to generateBranch - expect(execute).toBeCalledTimes(17) + expect(execute).toBeCalledTimes(18) expect(rmRF).toBeCalledTimes(1) }) @@ -382,7 +382,7 @@ describe('git', () => { await deploy(action) // Includes the call to generateBranch - expect(execute).toBeCalledTimes(11) + expect(execute).toBeCalledTimes(12) expect(rmRF).toBeCalledTimes(1) }) @@ -402,7 +402,7 @@ describe('git', () => { await deploy(action) // Includes the call to generateBranch - expect(execute).toBeCalledTimes(11) + expect(execute).toBeCalledTimes(12) expect(rmRF).toBeCalledTimes(1) }) @@ -421,7 +421,7 @@ describe('git', () => { await deploy(action) - expect(execute).toBeCalledTimes(11) + expect(execute).toBeCalledTimes(12) expect(rmRF).toBeCalledTimes(1) expect(mkdirP).toBeCalledTimes(1) }) @@ -439,7 +439,7 @@ describe('git', () => { }) const response = await deploy(action) - expect(execute).toBeCalledTimes(12) + expect(execute).toBeCalledTimes(13) expect(rmRF).toBeCalledTimes(1) expect(response).toBe(Status.SKIPPED) }) @@ -461,7 +461,7 @@ describe('git', () => { try { await deploy(action) } catch (e) { - expect(execute).toBeCalledTimes(0) + expect(execute).toBeCalledTimes(1) expect(rmRF).toBeCalledTimes(1) expect(e.message).toMatch( 'The deploy step encountered an error: No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true. ❌' diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 140ce144..4d7b1c87 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -47,7 +47,7 @@ describe('main', () => { debug: true }) await run(action) - expect(execute).toBeCalledTimes(18) + expect(execute).toBeCalledTimes(19) expect(rmRF).toBeCalledTimes(1) expect(exportVariable).toBeCalledTimes(1) }) @@ -64,7 +64,7 @@ describe('main', () => { } }) await run(action) - expect(execute).toBeCalledTimes(17) + expect(execute).toBeCalledTimes(18) expect(rmRF).toBeCalledTimes(1) expect(exportVariable).toBeCalledTimes(1) }) diff --git a/src/git.ts b/src/git.ts index 347e1454..1a39ac69 100644 --- a/src/git.ts +++ b/src/git.ts @@ -246,6 +246,10 @@ export async function deploy(action: ActionInterface): Promise { ) } finally { // Ensures the deployment directory is safely removed after each deployment. + await execute( + `git worktree remove ${temporaryDeploymentDirectory}`, + action.workspace + ) await rmRF(temporaryDeploymentDirectory) } }