mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Safe directory fix (#1085)
* Potential fix for safe directory issue * Update git.ts * Update git.ts
This commit is contained in:
parent
91c3cd74c3
commit
1230c334d1
@ -55,7 +55,7 @@ describe('git', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await init(action)
|
await init(action)
|
||||||
expect(execute).toBeCalledTimes(6)
|
expect(execute).toBeCalledTimes(7)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should catch when a function throws an error', async () => {
|
it('should catch when a function throws an error', async () => {
|
||||||
@ -102,7 +102,7 @@ describe('git', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await init(action)
|
await init(action)
|
||||||
expect(execute).toBeCalledTimes(6)
|
expect(execute).toBeCalledTimes(7)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not unset git config if a user is using ssh', async () => {
|
it('should not unset git config if a user is using ssh', async () => {
|
||||||
@ -124,7 +124,7 @@ describe('git', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await init(action)
|
await init(action)
|
||||||
expect(execute).toBeCalledTimes(5)
|
expect(execute).toBeCalledTimes(6)
|
||||||
|
|
||||||
process.env.CI = undefined
|
process.env.CI = undefined
|
||||||
})
|
})
|
||||||
@ -145,7 +145,7 @@ describe('git', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await init(action)
|
await init(action)
|
||||||
expect(execute).toBeCalledTimes(6)
|
expect(execute).toBeCalledTimes(7)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ describe('main', () => {
|
|||||||
debug: true
|
debug: true
|
||||||
})
|
})
|
||||||
await run(action)
|
await run(action)
|
||||||
expect(execute).toBeCalledTimes(16)
|
expect(execute).toBeCalledTimes(17)
|
||||||
expect(rmRF).toBeCalledTimes(1)
|
expect(rmRF).toBeCalledTimes(1)
|
||||||
expect(exportVariable).toBeCalledTimes(1)
|
expect(exportVariable).toBeCalledTimes(1)
|
||||||
})
|
})
|
||||||
@ -73,7 +73,7 @@ describe('main', () => {
|
|||||||
isTest: TestFlag.HAS_CHANGED_FILES
|
isTest: TestFlag.HAS_CHANGED_FILES
|
||||||
})
|
})
|
||||||
await run(action)
|
await run(action)
|
||||||
expect(execute).toBeCalledTimes(19)
|
expect(execute).toBeCalledTimes(20)
|
||||||
expect(rmRF).toBeCalledTimes(1)
|
expect(rmRF).toBeCalledTimes(1)
|
||||||
expect(exportVariable).toBeCalledTimes(1)
|
expect(exportVariable).toBeCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
10
src/git.ts
10
src/git.ts
@ -21,6 +21,16 @@ export async function init(action: ActionInterface): Promise<void | Error> {
|
|||||||
info(`Deploying using ${action.tokenType}… 🔑`)
|
info(`Deploying using ${action.tokenType}… 🔑`)
|
||||||
info('Configuring git…')
|
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(
|
await execute(
|
||||||
`git config user.name "${action.name}"`,
|
`git config user.name "${action.name}"`,
|
||||||
action.workspace,
|
action.workspace,
|
||||||
|
Loading…
Reference in New Issue
Block a user