MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / restoreWorkspace

Function restoreWorkspace

services/cloud-agent-next/src/workspace.ts:823–847  ·  view source on GitHub ↗
(
  session: ExecutionSession,
  workspacePath: string,
  branchName: string,
  options: RestoreWorkspaceOptions
)

Source from the content-addressed store, hash-verified

821 // credential helper. The sandbox gitCheckout API only posts the URL and
822 // does not document session-env inheritance.
823 const cloneArgs = ['git', 'clone', '--progress'];
824 if (shallow) {
825 cloneArgs.push('--depth', '1');
826 }
827 cloneArgs.push(cloneUrl, workspacePath);
828 const result = await timedExec(session, cloneArgs.map(shellQuote).join(' '), 'git.clone', {
829 timeoutMs: GIT_CLONE_TIMEOUT_MS,
830 });
831
832 if (result.exitCode !== 0) {
833 throw new Error(
834 `git clone failed with exit code ${result.exitCode ?? 'unknown'}: ${result.stderr || result.stdout}`
835 );
836 }
837
838 await updateGitAuthor(
839 session,
840 workspacePath,
841 gitAuthor ?? { name: 'Kilo Code Cloud', email: 'agent@kilocode.ai' }
842 );
843
844 logger.info('Successfully cloned generic git repository');
845 } catch (err) {
846 const errorMessage = err instanceof Error ? err.message : String(err);
847 logger.error('Git clone failed', {
848 error: sanitizeGitOutput(errorMessage),
849 gitUrl: sanitizedGitUrl,
850 });

Callers

nothing calls this directly

Calls 3

cloneGitRepoFunction · 0.85
cloneGitHubRepoFunction · 0.85
manageBranchFunction · 0.85

Tested by

no test coverage detected