8000 Update git.ts · CasP0/github-pages-deploy-action@a16ac09 · GitHub
[go: up one dir, main page]

Skip to content

Commit a16ac09

Browse files
committed
Update git.ts
1 parent afcfd7b commit a16ac09

File tree

1 file changed

+26
-41
lines changed

1 file changed

+26
-41
lines changed

src/git.ts

Lines changed: 26 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,37 @@ export async function init(action: ActionInterface): Promise<void | Error> {
2121
info(`Deploying using ${action.tokenType}… 🔑`)
2222
info('Configuring git…')
2323

24-
async function configureGit(throwOnError: boolean) {
25-
try {
26-
await execute(
27-
`git config --global --add safe.directory "${action.workspace}"`,
28-
action.workspace,
29-
action.silent
30-
)
24+
await execute(`git init`, action.workspace, action.silent)
3125

32-
await execute(
33-
`git config user.name "${action.name}"`,
34-
action.workspace,
35-
action.silent
36-
)
26+
await execute(
27+
`git commit -m "Initial commit" --allow-empty`,
28+
action.workspace,
29+
action.silent
30+
)
3731

38-
await execute(
39-
`git config user.email "${action.email}"`,
40-
action.workspace,
41-
action.silent
42-
)
32+
await execute(
33+
`git config --global --add safe.directory "${action.workspace}"`,
34+
action.workspace,
35+
action.silent
36+
)
4337

44-
await execute(
45-
`git config core.ignorecase false`,
46-
action.workspace,
47-
action.silent
48-
)
49-
} catch {
50-
if (throwOnError) {
51-
throw new Error()
52-
}
53-
}
54-
}
38+
await execute(
39+
`git config user.name "${action.name}"`,
40+
action.workspace,
41+
action.silent
42+
)
5543

56-
try {
57-
await configureGit(false)
58-
} catch {
59-
// Attempt to re-run if initial configuration failed using git init.
60-
await execute(`git init`, action.workspace, action.silent)
44+
await execute(
45+
`git config user.email "${action.email}"`,
46+
action.workspace,
47+
action.silent
48+
)
6149

62-
await execute(
63-
`git commit -m "Initial commit" --allow-empty`,
64-
action.workspace,
65-
action.silent
66-
)
67-
68-
await configureGit(true)
69-
}
50+
await execute(
51+
`git config core.ignorecase false`,
52+
action.workspace,
53+
action.silent
54+
)
7055

7156
try {
7257
if ((process.env.CI && !action.sshKey) || action.isTest) {

0 commit comments

Comments
 (0)
0