(
projectPath: string,
containerName: string,
workspacePath: string,
initLogger: InitLogger,
abortSignal?: AbortSignal,
trusted?: boolean
)
| 824 | } |
| 825 | |
| 826 | private async syncProjectToContainer( |
| 827 | projectPath: string, |
| 828 | containerName: string, |
| 829 | workspacePath: string, |
| 830 | initLogger: InitLogger, |
| 831 | abortSignal?: AbortSignal, |
| 832 | trusted?: boolean |
| 833 | ): Promise<void> { |
| 834 | const timestamp = Date.now(); |
| 835 | const bundleFilename = `mux-bundle-${timestamp}.bundle`; |
| 836 | const remoteBundlePath = `/tmp/${bundleFilename}`; |
| 837 | // Use os.tmpdir() for host path (Windows doesn't have /tmp) |
| 838 | const localBundlePath = path.join(os.tmpdir(), bundleFilename); |
| 839 | |
| 840 | await syncProjectViaGitBundle({ |
| 841 | projectPath, |
| 842 | workspacePath, |
| 843 | remoteTmpDir: "/tmp", |
| 844 | remoteBundlePath, |
| 845 | exec: (command, options) => this.exec(command, options), |
| 846 | quoteRemotePath: (path) => this.quoteForRemote(path), |
| 847 | initLogger, |
| 848 | abortSignal, |
| 849 | cloneStep: "Cloning repository in container...", |
| 850 | trusted, |
| 851 | createRemoteBundle: async ({ remoteBundlePath, initLogger, abortSignal }) => { |
| 852 | try { |
| 853 | if (abortSignal?.aborted) { |
| 854 | throw new Error("Sync operation aborted before starting"); |
| 855 | } |
| 856 | |
| 857 | const bundleResult = await runDockerCommand( |
| 858 | `git -C "${projectPath}" bundle create "${localBundlePath}" --all`, |
| 859 | 300000 |
| 860 | ); |
| 861 | |
| 862 | if (bundleResult.exitCode !== 0) { |
| 863 | throw new Error(`Failed to create bundle: ${bundleResult.stderr}`); |
| 864 | } |
| 865 | |
| 866 | initLogger.logStep("Copying bundle to container..."); |
| 867 | const copyResult = await runDockerCommand( |
| 868 | `docker cp "${localBundlePath}" ${containerName}:${remoteBundlePath}`, |
| 869 | 300000 |
| 870 | ); |
| 871 | |
| 872 | if (copyResult.exitCode !== 0) { |
| 873 | throw new Error(`Failed to copy bundle: ${copyResult.stderr}`); |
| 874 | } |
| 875 | |
| 876 | return { |
| 877 | cleanupLocal: async () => { |
| 878 | await runDockerCommand(`rm -f "${localBundlePath}"`, 5000); |
| 879 | }, |
| 880 | }; |
| 881 | } catch (error) { |
| 882 | await runDockerCommand(`rm -f "${localBundlePath}"`, 5000); |
| 883 | throw error; |
no test coverage detected