mirror of
https://code.forgejo.org/actions/checkout.git
synced 2026-03-28 16:03:07 +00:00
fix: ensure symlinked git directories work
This commit is contained in:
parent
0c366fd6a8
commit
70525c3952
3 changed files with 102 additions and 12 deletions
15
dist/index.js
vendored
15
dist/index.js
vendored
|
|
@ -406,9 +406,18 @@ class GitAuthHelper {
|
|||
);
|
||||
}
|
||||
else {
|
||||
// Host git directory
|
||||
let gitDir = path.join(this.git.getWorkingDirectory(), '.git');
|
||||
gitDir = gitDir.replace(/\\/g, '/'); // Use forward slashes, even on Windows
|
||||
// Host git directory - resolve symlinks so includeIf gitdir matching works
|
||||
// on self-hosted runners where _work is a symlink to an external volume.
|
||||
let gitDir;
|
||||
try {
|
||||
const constructed = path.join(this.git.getWorkingDirectory(), '.git');
|
||||
gitDir = fs.realpathSync(constructed).replace(/\\/g, '/');
|
||||
}
|
||||
catch (_a) {
|
||||
// Fall back to constructed path if realpathSync fails
|
||||
gitDir = path.join(this.git.getWorkingDirectory(), '.git');
|
||||
gitDir = gitDir.replace(/\\/g, '/');
|
||||
}
|
||||
// Configure host includeIf
|
||||
const hostIncludeKey = `includeIf.gitdir:${gitDir}.path`;
|
||||
yield this.git.config(hostIncludeKey, credentialsConfigPath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue