Skip to content

Commit 590faa7

Browse files
grichaclaude
andauthored
Fix --clone flag not working when starting workspace (#34)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 15d712e commit 590faa7

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

perry/internal/src/commands/entrypoint.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { addSshKeys } from "./add-ssh-key";
2+
import { runInit } from "./init";
23
import { syncUserWithHost } from "./sync-user";
34
import { ensureDockerd, monitorServices, startSshd, tailDockerdLogs, waitForDocker } from "../lib/services";
45

@@ -18,6 +19,8 @@ export const runEntrypoint = async () => {
1819
process.exit(1);
1920
return;
2021
}
22+
console.log("[entrypoint] Running workspace initialization...");
23+
await runInit();
2124
console.log("[entrypoint] Starting SSH daemon...");
2225
await startSshd();
2326
void monitorServices();

test/integration/cli.test.ts

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,51 @@ describe('CLI commands', () => {
5454
await agent.api.deleteWorkspace(name);
5555
});
5656

57-
it('creates workspace with --clone option', async () => {
57+
it('creates workspace with --clone option and clones the repository', async () => {
5858
const name = generateTestWorkspaceName();
59-
const result = await runCLI(['start', name, '--clone', 'https://github.com/example/repo'], {
59+
const repoUrl = 'https://github.com/octocat/Hello-World';
60+
const result = await runCLI(['start', name, '--clone', repoUrl], {
6061
env: cliEnv(),
61-
timeout: 30000,
62+
timeout: 90000,
6263
});
6364
expect(result.code).toBe(0);
6465
expect(result.stdout).toContain(`Workspace '${name}' started`);
6566

67+
const { execInContainer } = await import('../../src/docker');
68+
const containerName = `workspace-${name}`;
69+
70+
const waitForInit = async (maxWait = 60000) => {
71+
const start = Date.now();
72+
while (Date.now() - start < maxWait) {
73+
const check = await execInContainer(
74+
containerName,
75+
['test', '-f', '/home/workspace/.workspace-initialized'],
76+
{ user: 'workspace' }
77+
);
78+
if (check.exitCode === 0) return true;
79+
await new Promise((r) => setTimeout(r, 1000));
80+
}
81+
return false;
82+
};
83+
84+
const initComplete = await waitForInit();
85+
expect(initComplete).toBe(true);
86+
87+
const lsResult = await execInContainer(containerName, ['ls', '-la', '/home/workspace'], {
88+
user: 'root',
89+
});
90+
expect(lsResult.exitCode).toBe(0);
91+
expect(lsResult.stdout).toContain('Hello-World');
92+
93+
const gitDirResult = await execInContainer(
94+
containerName,
95+
['test', '-d', '/home/workspace/Hello-World/.git'],
96+
{ user: 'root' }
97+
);
98+
expect(gitDirResult.exitCode).toBe(0);
99+
66100
await agent.api.deleteWorkspace(name);
67-
});
101+
}, 120000);
68102

69103
it('starts existing workspace without error', async () => {
70104
const name = generateTestWorkspaceName();

0 commit comments

Comments
 (0)