diff --git a/dist/index.js b/dist/index.js index 0a33ea1..36689d5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7129,8 +7129,17 @@ class GitAuthHelper { } } if (configExists) { - core.info(`Copying '${gitConfigPath}' to '${newGitConfigPath}'`); - yield io.cp(gitConfigPath, newGitConfigPath); + if ((yield fs.promises.lstat(gitConfigPath)).isSymbolicLink()) { + core.info(`.gitconfig file at ${gitConfigPath} is a symlink, copying the true file instead`); + // get true link + const symlinkFull = yield fs.promises.readlink(gitConfigPath); + core.info(`Copying '${symlinkFull}' to '${newGitConfigPath}'`); + yield io.cp(symlinkFull, newGitConfigPath); + } + else { + core.info(`Copying '${gitConfigPath}' to '${newGitConfigPath}'`); + yield io.cp(gitConfigPath, newGitConfigPath); + } } else { yield fs.promises.writeFile(newGitConfigPath, ''); diff --git a/src/git-auth-helper.ts b/src/git-auth-helper.ts index 6e3ad28..ac84020 100644 --- a/src/git-auth-helper.ts +++ b/src/git-auth-helper.ts @@ -109,8 +109,16 @@ class GitAuthHelper { } } if (configExists) { - core.info(`Copying '${gitConfigPath}' to '${newGitConfigPath}'`) - await io.cp(gitConfigPath, newGitConfigPath) + if ((await fs.promises.lstat(gitConfigPath)).isSymbolicLink()) { + core.info(`.gitconfig file at ${gitConfigPath} is a symlink, copying the true file instead`) + // get true link + const symlinkFull: string = await fs.promises.readlink(gitConfigPath) + core.info(`Copying '${symlinkFull}' to '${newGitConfigPath}'`) + await io.cp(symlinkFull, newGitConfigPath) + } else { + core.info(`Copying '${gitConfigPath}' to '${newGitConfigPath}'`) + await io.cp(gitConfigPath, newGitConfigPath) + } } else { await fs.promises.writeFile(newGitConfigPath, '') }