mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-04-21 09:10:16 +03: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:
parent
230611dbd0
commit
6bf54c5e8a
2 changed files with 22 additions and 5 deletions
|
@ -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, '')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue