Safe directory fix (#1085)

* Potential fix for safe directory issue

* Update git.ts

* Update git.ts
This commit is contained in:
James Ives 2022-04-23 15:04:53 -04:00 committed by GitHub
parent 91c3cd74c3
commit 1230c334d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View File

@ -55,7 +55,7 @@ describe('git', () => {
})
await init(action)
expect(execute).toBeCalledTimes(6)
expect(execute).toBeCalledTimes(7)
})
it('should catch when a function throws an error', async () => {
@ -102,7 +102,7 @@ describe('git', () => {
})
await init(action)
expect(execute).toBeCalledTimes(6)
expect(execute).toBeCalledTimes(7)
})
it('should not unset git config if a user is using ssh', async () => {
@ -124,7 +124,7 @@ describe('git', () => {
})
await init(action)
expect(execute).toBeCalledTimes(5)
expect(execute).toBeCalledTimes(6)
process.env.CI = undefined
})
@ -145,7 +145,7 @@ describe('git', () => {
})
await init(action)
expect(execute).toBeCalledTimes(6)
expect(execute).toBeCalledTimes(7)
})
})

View File

@ -53,7 +53,7 @@ describe('main', () => {
debug: true
})
await run(action)
expect(execute).toBeCalledTimes(16)
expect(execute).toBeCalledTimes(17)
expect(rmRF).toBeCalledTimes(1)
expect(exportVariable).toBeCalledTimes(1)
})
@ -73,7 +73,7 @@ describe('main', () => {
isTest: TestFlag.HAS_CHANGED_FILES
})
await run(action)
expect(execute).toBeCalledTimes(19)
expect(execute).toBeCalledTimes(20)
expect(rmRF).toBeCalledTimes(1)
expect(exportVariable).toBeCalledTimes(1)
})

View File

@ -21,6 +21,16 @@ export async function init(action: ActionInterface): Promise<void | Error> {
info(`Deploying using ${action.tokenType}… 🔑`)
info('Configuring git…')
try {
await execute(
`git config --global --add safe.directory "${action.workspace}"`,
action.workspace,
action.silent
)
} catch {
info('Unable to set workspace as a safe directory…')
}
await execute(
`git config user.name "${action.name}"`,
action.workspace,