(path: string, onProgress?: onProgressFn, signal?: AbortSignal)
| 35 | * set to the given path. |
| 36 | */ |
| 37 | const createGitClientForPath = (path: string, onProgress?: onProgressFn, signal?: AbortSignal) => { |
| 38 | if (!existsSync(path)) { |
| 39 | throw new Error(`Path ${path} does not exist`); |
| 40 | } |
| 41 | |
| 42 | const parentPath = resolve(dirname(path)); |
| 43 | |
| 44 | const git = simpleGit({ |
| 45 | progress: onProgress, |
| 46 | abort: signal, |
| 47 | unsafe, |
| 48 | }) |
| 49 | .env({ |
| 50 | ...process.env, |
| 51 | /** |
| 52 | * @note on some inside-baseball on why this is necessary: The specific |
| 53 | * issue we saw was that a `git clone` would fail without throwing, and |
| 54 | * then a subsequent `git config` command would run, but since the clone |
| 55 | * failed, it wouldn't be running in a git directory. Git would then walk |
| 56 | * up the directory tree until it either found a git directory (in the case |
| 57 | * of the development env) or it would hit a GIT_DISCOVERY_ACROSS_FILESYSTEM |
| 58 | * error when trying to cross a filesystem boundary (in the prod case). |
| 59 | * GIT_CEILING_DIRECTORIES ensures that this walk will be limited to the |
| 60 | * parent directory. |
| 61 | */ |
| 62 | GIT_CEILING_DIRECTORIES: parentPath, |
| 63 | /** |
| 64 | * Disable git credential prompts. This ensures that git operations will fail |
| 65 | * immediately if credentials are not available, rather than prompting for input. |
| 66 | */ |
| 67 | GIT_TERMINAL_PROMPT: '0', |
| 68 | }) |
| 69 | .cwd({ |
| 70 | path, |
| 71 | }); |
| 72 | |
| 73 | return git; |
| 74 | } |
| 75 | |
| 76 | export const cloneRepository = async ( |
| 77 | { |
no outgoing calls
no test coverage detected