Skip to content

Commit

Permalink
Removes the call to -D (#713)
Browse files Browse the repository at this point in the history
* Removes the call to -D

* Update main.test.ts
  • Loading branch information
JamesIves authored May 11, 2021
1 parent fa74174 commit 6c2a931
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
20 changes: 10 additions & 10 deletions __tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('git', () => {
const response = await deploy(action)

// Includes the call to generateWorktree
expect(execute).toBeCalledTimes(13)
expect(execute).toBeCalledTimes(12)
expect(rmRF).toBeCalledTimes(1)
expect(response).toBe(Status.SUCCESS)
})
Expand All @@ -191,7 +191,7 @@ describe('git', () => {
const response = await deploy(action)

// Includes the call to generateWorktree
expect(execute).toBeCalledTimes(12)
expect(execute).toBeCalledTimes(11)
expect(rmRF).toBeCalledTimes(1)
expect(response).toBe(Status.SUCCESS)
})
Expand All @@ -216,7 +216,7 @@ describe('git', () => {
await deploy(action)

// Includes the call to generateWorktree
expect(execute).toBeCalledTimes(10)
expect(execute).toBeCalledTimes(11)
expect(rmRF).toBeCalledTimes(1)
})

Expand All @@ -240,7 +240,7 @@ describe('git', () => {
await deploy(action)

// Includes the call to generateWorktree
expect(execute).toBeCalledTimes(9)
expect(execute).toBeCalledTimes(10)
expect(rmRF).toBeCalledTimes(1)
})

Expand All @@ -265,7 +265,7 @@ describe('git', () => {
await deploy(action)

// Includes the call to generateWorktree
expect(execute).toBeCalledTimes(9)
expect(execute).toBeCalledTimes(10)
expect(rmRF).toBeCalledTimes(1)
})

Expand Down Expand Up @@ -296,7 +296,7 @@ describe('git', () => {
const response = await deploy(action)

// Includes the call to generateWorktree
expect(execute).toBeCalledTimes(13)
expect(execute).toBeCalledTimes(12)
expect(rmRF).toBeCalledTimes(1)
expect(fs.existsSync).toBeCalledTimes(2)
expect(response).toBe(Status.SUCCESS)
Expand Down Expand Up @@ -328,7 +328,7 @@ describe('git', () => {
await deploy(action)

// Includes the call to generateWorktree
expect(execute).toBeCalledTimes(10)
expect(execute).toBeCalledTimes(9)
expect(rmRF).toBeCalledTimes(1)
})
})
Expand All @@ -353,7 +353,7 @@ describe('git', () => {
await deploy(action)

// Includes the call to generateWorktree
expect(execute).toBeCalledTimes(10)
expect(execute).toBeCalledTimes(9)
expect(rmRF).toBeCalledTimes(1)
})

Expand All @@ -373,7 +373,7 @@ describe('git', () => {

await deploy(action)

expect(execute).toBeCalledTimes(10)
expect(execute).toBeCalledTimes(9)
expect(rmRF).toBeCalledTimes(1)
expect(mkdirP).toBeCalledTimes(1)
})
Expand All @@ -393,7 +393,7 @@ describe('git', () => {
})

const response = await deploy(action)
expect(execute).toBeCalledTimes(10)
expect(execute).toBeCalledTimes(9)
expect(rmRF).toBeCalledTimes(1)
expect(response).toBe(Status.SKIPPED)
})
Expand Down
4 changes: 2 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('main', () => {
debug: true
})
await run(action)
expect(execute).toBeCalledTimes(15)
expect(execute).toBeCalledTimes(14)
expect(rmRF).toBeCalledTimes(1)
expect(exportVariable).toBeCalledTimes(1)
})
Expand All @@ -69,7 +69,7 @@ describe('main', () => {
isTest: TestFlag.HAS_CHANGED_FILES
})
await run(action)
expect(execute).toBeCalledTimes(18)
expect(execute).toBeCalledTimes(17)
expect(rmRF).toBeCalledTimes(1)
expect(exportVariable).toBeCalledTimes(1)
})
Expand Down
19 changes: 5 additions & 14 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,11 @@ export async function deploy(action: ActionInterface): Promise<Status> {
// Cleans up temporary files/folders and restores the git state.
info('Running post deployment cleanup jobs… 🗑️')

if (!action.singleCommit) {
info(`Resetting branch and removing artifacts…`)
await execute(
`git checkout -B ${temporaryDeploymentBranch}`,
`${action.workspace}/${temporaryDeploymentDirectory}`,
action.silent
)

await execute(
`git branch -D ${action.branch} --force`,
action.workspace,
action.silent
)
}
await execute(
`git checkout -B ${temporaryDeploymentBranch}`,
`${action.workspace}/${temporaryDeploymentDirectory}`,
action.silent
)

await execute(
`git worktree remove ${temporaryDeploymentDirectory} --force`,
Expand Down

0 comments on commit 6c2a931

Please sign in to comment.