mirror of
https://github.com/actions/checkout.git
synced 2025-12-15 14:59:24 +00:00
Check for symlinked gitconfig
We don't want to edit the user's actual gitconfig, we only want to copy their setup. If the file is symlinked, we resolve the link and copy the source file instead.
This commit is contained in:
@@ -104,8 +104,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, '')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user