Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/cli/src/config/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const mockGit = {
getRemotes: vi.fn(),
fetch: vi.fn(),
checkout: vi.fn(),
submoduleUpdate: vi.fn(),
listRemote: vi.fn(),
revparse: vi.fn(),
// Not a part of the actual API, but we need to use this to do the correct
Expand Down
6 changes: 6 additions & 0 deletions packages/cli/src/config/extensions/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ describe('github.ts', () => {
getRemotes: ReturnType<typeof vi.fn>;
fetch: ReturnType<typeof vi.fn>;
checkout: ReturnType<typeof vi.fn>;
submoduleUpdate: ReturnType<typeof vi.fn>;
listRemote: ReturnType<typeof vi.fn>;
revparse: ReturnType<typeof vi.fn>;
};
Expand All @@ -83,6 +84,7 @@ describe('github.ts', () => {
getRemotes: vi.fn(),
fetch: vi.fn(),
checkout: vi.fn(),
submoduleUpdate: vi.fn(),
listRemote: vi.fn(),
revparse: vi.fn(),
};
Expand All @@ -108,6 +110,10 @@ describe('github.ts', () => {
);
expect(mockGit.fetch).toHaveBeenCalledWith('origin', 'v1.0.0');
expect(mockGit.checkout).toHaveBeenCalledWith('FETCH_HEAD');
expect(mockGit.submoduleUpdate).toHaveBeenCalledWith([
'--init',
'--recursive',
]);
});

it('should throw if no remotes found', async () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/config/extensions/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export async function cloneFromGit(
// After fetching, checkout FETCH_HEAD to get the content of the fetched ref.
// This results in a detached HEAD state, which is fine for this purpose.
await git.checkout('FETCH_HEAD');

// Some extensions vendor code or assets via git submodules. Initialize
// them after checking out the requested ref so they match that commit.
await git.submoduleUpdate(['--init', '--recursive']);
} catch (error) {
throw new Error(
`Failed to clone Git repository from ${installMetadata.source} ${getErrorMessage(error)}`,
Expand Down