Skip to content

Commit 771fdd4

Browse files
committed
2 parents e6e8596 + 74a410d commit 771fdd4

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

__tests__/git.test.ts

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

169169
// Includes the call to generateWorktree
170-
expect(execute).toHaveBeenCalledTimes(14)
170+
expect(execute).toHaveBeenCalledTimes(15)
171171
expect(rmRF).toHaveBeenCalledTimes(1)
172172
expect(response).toBe(Status.SUCCESS)
173173
})
@@ -190,7 +190,7 @@ describe('git', () => {
190190
const response = await deploy(action)
191191

192192
// Includes the call to generateWorktree
193-
expect(execute).toHaveBeenCalledTimes(13)
193+
expect(execute).toHaveBeenCalledTimes(14)
194194
expect(rmRF).toHaveBeenCalledTimes(1)
195195
expect(response).toBe(Status.SUCCESS)
196196
})
@@ -215,7 +215,7 @@ describe('git', () => {
215215
await deploy(action)
216216

217217
// Includes the call to generateWorktree
218-
expect(execute).toHaveBeenCalledTimes(14)
218+
expect(execute).toHaveBeenCalledTimes(15)
219219
expect(rmRF).toHaveBeenCalledTimes(1)
220220
})
221221

@@ -264,7 +264,7 @@ describe('git', () => {
264264
await deploy(action)
265265

266266
// Includes the call to generateWorktree
267-
expect(execute).toHaveBeenCalledTimes(13)
267+
expect(execute).toHaveBeenCalledTimes(14)
268268
expect(rmRF).toHaveBeenCalledTimes(1)
269269
})
270270

@@ -295,7 +295,7 @@ describe('git', () => {
295295
const response = await deploy(action)
296296

297297
// Includes the call to generateWorktree
298-
expect(execute).toHaveBeenCalledTimes(14)
298+
expect(execute).toHaveBeenCalledTimes(15)
299299
expect(rmRF).toHaveBeenCalledTimes(1)
300300
expect(fs.existsSync).toHaveBeenCalledTimes(2)
301301
expect(response).toBe(Status.SUCCESS)
@@ -327,7 +327,7 @@ describe('git', () => {
327327
await deploy(action)
328328

329329
// Includes the call to generateWorktree
330-
expect(execute).toHaveBeenCalledTimes(11)
330+
expect(execute).toHaveBeenCalledTimes(12)
331331
expect(rmRF).toHaveBeenCalledTimes(1)
332332
})
333333
})
@@ -352,7 +352,7 @@ describe('git', () => {
352352
await deploy(action)
353353

354354
// Includes the call to generateWorktree
355-
expect(execute).toHaveBeenCalledTimes(11)
355+
expect(execute).toHaveBeenCalledTimes(12)
356356
expect(rmRF).toHaveBeenCalledTimes(1)
357357
})
358358

@@ -372,7 +372,7 @@ describe('git', () => {
372372

373373
await deploy(action)
374374

375-
expect(execute).toHaveBeenCalledTimes(11)
375+
expect(execute).toHaveBeenCalledTimes(12)
376376
expect(rmRF).toHaveBeenCalledTimes(1)
377377
expect(mkdirP).toHaveBeenCalledTimes(1)
378378
})
@@ -392,7 +392,7 @@ describe('git', () => {
392392
})
393393

394394
const response = await deploy(action)
395-
expect(execute).toHaveBeenCalledTimes(11)
395+
expect(execute).toHaveBeenCalledTimes(12)
396396
expect(rmRF).toHaveBeenCalledTimes(1)
397397
expect(response).toBe(Status.SKIPPED)
398398
})
@@ -466,7 +466,7 @@ describe('git', () => {
466466
})
467467

468468
const response = await deploy(action)
469-
expect(execute).toHaveBeenCalledTimes(16)
469+
expect(execute).toHaveBeenCalledTimes(17)
470470
expect(response).toBe(Status.SUCCESS)
471471
})
472472
})

__tests__/main.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('main', () => {
5353
debug: true
5454
})
5555
await run(action)
56-
expect(execute).toHaveBeenCalledTimes(18)
56+
expect(execute).toHaveBeenCalledTimes(19)
5757
expect(rmRF).toHaveBeenCalledTimes(1)
5858
expect(exportVariable).toHaveBeenCalledTimes(1)
5959
})
@@ -73,7 +73,7 @@ describe('main', () => {
7373
isTest: TestFlag.HAS_CHANGED_FILES
7474
})
7575
await run(action)
76-
expect(execute).toHaveBeenCalledTimes(21)
76+
expect(execute).toHaveBeenCalledTimes(22)
7777
expect(rmRF).toHaveBeenCalledTimes(1)
7878
expect(exportVariable).toHaveBeenCalledTimes(1)
7979
})

src/worktree.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@ export async function generateWorktree(
128128
action.silent
129129
)
130130
}
131+
132+
/**
133+
* Ensure that the workspace is a safe directory.
134+
*/
135+
try {
136+
await execute(
137+
`git config --global --add safe.directory "${action.workspace}/${worktreedir}"`,
138+
action.workspace,
139+
action.silent
140+
)
141+
} catch {
142+
info('Unable to set worktree temp directory as a safe directory…')
143+
}
131144
}
132145
} catch (error) {
133146
throw new Error(

0 commit comments

Comments
 (0)