Update git.ts

This commit is contained in:
James Ives 2022-04-27 10:40:50 -04:00
parent afcfd7b3a1
commit a16ac09dc1

View File

@ -21,8 +21,14 @@ 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…')
async function configureGit(throwOnError: boolean) { await execute(`git init`, action.workspace, action.silent)
try {
await execute(
`git commit -m "Initial commit" --allow-empty`,
action.workspace,
action.silent
)
await execute( await execute(
`git config --global --add safe.directory "${action.workspace}"`, `git config --global --add safe.directory "${action.workspace}"`,
action.workspace, action.workspace,
@ -46,27 +52,6 @@ export async function init(action: ActionInterface): Promise<void | Error> {
action.workspace, action.workspace,
action.silent action.silent
) )
} catch {
if (throwOnError) {
throw new Error()
}
}
}
try {
await configureGit(false)
} catch {
// Attempt to re-run if initial configuration failed using git init.
await execute(`git init`, action.workspace, action.silent)
await execute(
`git commit -m "Initial commit" --allow-empty`,
action.workspace,
action.silent
)
await configureGit(true)
}
try { try {
if ((process.env.CI && !action.sshKey) || action.isTest) { if ((process.env.CI && !action.sshKey) || action.isTest) {