Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions packages/core/src/extension/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('git extension helpers', () => {
});

it('should clone, fetch and checkout a repo', async () => {
mockPlatform.mockReturnValue('linux');
const installMetadata = {
source: 'http://my-repo.com',
ref: 'my-ref',
Expand All @@ -79,6 +80,50 @@ describe('git extension helpers', () => {
expect(mockGit.checkout).toHaveBeenCalledWith('FETCH_HEAD');
});

it('should use core.symlinks=false on Windows to avoid permission errors', async () => {
mockPlatform.mockReturnValue('win32');
const installMetadata = {
source: 'http://my-repo.com',
ref: 'my-ref',
type: 'git' as const,
};
const destination = '/dest';
mockGit.getRemotes.mockResolvedValue([
{ name: 'origin', refs: { fetch: 'http://my-repo.com' } },
]);

await cloneFromGit(installMetadata, destination);

expect(mockGit.clone).toHaveBeenCalledWith('http://my-repo.com', './', [
'-c',
'core.symlinks=false',
'--depth',
'1',
]);
});

it('should use core.symlinks=true on non-Windows platforms', async () => {
mockPlatform.mockReturnValue('darwin');
const installMetadata = {
source: 'http://my-repo.com',
ref: 'my-ref',
type: 'git' as const,
};
const destination = '/dest';
mockGit.getRemotes.mockResolvedValue([
{ name: 'origin', refs: { fetch: 'http://my-repo.com' } },
]);

await cloneFromGit(installMetadata, destination);

expect(mockGit.clone).toHaveBeenCalledWith('http://my-repo.com', './', [
'-c',
'core.symlinks=true',
'--depth',
'1',
]);
});

it('should use HEAD if ref is not provided', async () => {
const installMetadata = {
source: 'http://my-repo.com',
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/extension/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ export async function cloneFromGit(
// We let git handle the source as is.
}
}
// On Windows, symlinks require elevated privileges by default, so we
// disable them to avoid "Permission denied" errors during checkout.
const symlinkValue = os.platform() === 'win32' ? 'false' : 'true';
await git.clone(sourceUrl, './', [
'-c',
'core.symlinks=true',
`core.symlinks=${symlinkValue}`,
'--depth',
'1',
]);
Expand Down
Loading