MCPcopy
hub / github.com/coder/mux / writeFakeGitCloneEnvLoggingShim

Function writeFakeGitCloneEnvLoggingShim

src/node/services/projectService.test.ts:720–745  ·  view source on GitHub ↗
(
      fakeGitPath: string,
      options: { failIfSshAskpassIsSet: boolean }
    )

Source from the content-addressed store, hash-verified

718 }
719
720 async function writeFakeGitCloneEnvLoggingShim(
721 fakeGitPath: string,
722 options: { failIfSshAskpassIsSet: boolean }
723 ): Promise<void> {
724 const sshAskpassGuard = options.failIfSshAskpassIsSet
725 ? `
726 if [ -n "$SSH_ASKPASS" ]; then
727 echo "Unexpected SSH_ASKPASS for non-SSH clone" >&2
728 exit 128
729 fi`
730 : "";
731
732 await fs.writeFile(
733 fakeGitPath,
734 `#!/bin/sh
735if [ "$1" = "clone" ]; then
736 printf 'SSH_ASKPASS=%s\nSSH_ASKPASS_REQUIRE=%s\nGIT_TERMINAL_PROMPT=%s\n' "\${SSH_ASKPASS:-}" "\${SSH_ASKPASS_REQUIRE:-}" "\${GIT_TERMINAL_PROMPT:-}" > "$FAKE_GIT_ENV_LOG"${sshAskpassGuard}
737 mkdir -p "$5/.git"
738 exit 0
739fi
740exit 1
741`,
742 "utf-8"
743 );
744 await fs.chmod(fakeGitPath, 0o755);
745 }
746
747 async function cloneAndCaptureAskpassEnv(options: {
748 testCaseId: string;

Callers 1

Calls 1

writeFileMethod · 0.65

Tested by

no test coverage detected