Skip to content

Commit 0657078

Browse files
authored
Removes the worktree (JamesIves#309)
* Removes the worktree * Tests
1 parent ebb288a commit 0657078

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

__tests__/git.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ describe('git', () => {
341341
const response = await deploy(action)
342342

343343
// Includes the call to generateBranch
344-
expect(execute).toBeCalledTimes(11)
344+
expect(execute).toBeCalledTimes(12)
345345
expect(rmRF).toBeCalledTimes(1)
346346
expect(response).toBe(Status.SUCCESS)
347347
})
@@ -361,7 +361,7 @@ describe('git', () => {
361361
await deploy(action)
362362

363363
// Includes the call to generateBranch
364-
expect(execute).toBeCalledTimes(17)
364+
expect(execute).toBeCalledTimes(18)
365365
expect(rmRF).toBeCalledTimes(1)
366366
})
367367

@@ -382,7 +382,7 @@ describe('git', () => {
382382
await deploy(action)
383383

384384
// Includes the call to generateBranch
385-
expect(execute).toBeCalledTimes(11)
385+
expect(execute).toBeCalledTimes(12)
386386
expect(rmRF).toBeCalledTimes(1)
387387
})
388388

@@ -402,7 +402,7 @@ describe('git', () => {
402402
await deploy(action)
403403

404404
// Includes the call to generateBranch
405-
expect(execute).toBeCalledTimes(11)
405+
expect(execute).toBeCalledTimes(12)
406406
expect(rmRF).toBeCalledTimes(1)
407407
})
408408

@@ -421,7 +421,7 @@ describe('git', () => {
421421

422422
await deploy(action)
423423

424-
expect(execute).toBeCalledTimes(11)
424+
expect(execute).toBeCalledTimes(12)
425425
expect(rmRF).toBeCalledTimes(1)
426426
expect(mkdirP).toBeCalledTimes(1)
427427
})
@@ -439,7 +439,7 @@ describe('git', () => {
439439
})
440440

441441
const response = await deploy(action)
442-
expect(execute).toBeCalledTimes(12)
442+
expect(execute).toBeCalledTimes(13)
443443
expect(rmRF).toBeCalledTimes(1)
444444
expect(response).toBe(Status.SKIPPED)
445445
})
@@ -461,7 +461,7 @@ describe('git', () => {
461461
try {
462462
await deploy(action)
463463
} catch (e) {
464-
expect(execute).toBeCalledTimes(0)
464+
expect(execute).toBeCalledTimes(1)
465465
expect(rmRF).toBeCalledTimes(1)
466466
expect(e.message).toMatch(
467467
'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. ❌'

__tests__/main.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('main', () => {
4747
debug: true
4848
})
4949
await run(action)
50-
expect(execute).toBeCalledTimes(18)
50+
expect(execute).toBeCalledTimes(19)
5151
expect(rmRF).toBeCalledTimes(1)
5252
expect(exportVariable).toBeCalledTimes(1)
5353
})
@@ -64,7 +64,7 @@ describe('main', () => {
6464
}
6565
})
6666
await run(action)
67-
expect(execute).toBeCalledTimes(17)
67+
expect(execute).toBeCalledTimes(18)
6868
expect(rmRF).toBeCalledTimes(1)
6969
expect(exportVariable).toBeCalledTimes(1)
7070
})

src/git.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ export async function deploy(action: ActionInterface): Promise<Status> {
246246
)
247247
} finally {
248248
// Ensures the deployment directory is safely removed after each deployment.
249+
await execute(
250+
`git worktree remove ${temporaryDeploymentDirectory}`,
251+
action.workspace
252+
)
249253
await rmRF(temporaryDeploymentDirectory)
250254
}
251255
}

0 commit comments

Comments
 (0)