( cwd: string, sparsePaths: string[] | undefined, )
| 1032 | * trigger the clone path, which establishes the correct state from scratch. |
| 1033 | */ |
| 1034 | export async function reconcileSparseCheckout( |
| 1035 | cwd: string, |
| 1036 | sparsePaths: string[] | undefined, |
| 1037 | ): Promise<{ code: number; stderr: string }> { |
| 1038 | const env = { ...process.env, ...GIT_NO_PROMPT_ENV } |
| 1039 | |
| 1040 | if (sparsePaths && sparsePaths.length > 0) { |
| 1041 | return execFileNoThrowWithCwd( |
| 1042 | gitExe(), |
| 1043 | ['sparse-checkout', 'set', '--cone', '--', ...sparsePaths], |
| 1044 | { cwd, timeout: getPluginGitTimeoutMs(), stdin: 'ignore', env }, |
| 1045 | ) |
| 1046 | } |
| 1047 | |
| 1048 | const check = await execFileNoThrowWithCwd( |
| 1049 | gitExe(), |
| 1050 | ['config', '--get', 'core.sparseCheckout'], |
| 1051 | { cwd, stdin: 'ignore', env }, |
| 1052 | ) |
| 1053 | if (check.code === 0 && check.stdout.trim() === 'true') { |
| 1054 | return { |
| 1055 | code: 1, |
| 1056 | stderr: |
| 1057 | 'sparsePaths removed from config but repository is sparse; re-cloning for full checkout', |
| 1058 | } |
| 1059 | } |
| 1060 | return { code: 0, stderr: '' } |
| 1061 | } |
| 1062 | |
| 1063 | /** |
| 1064 | * Cache a marketplace from a git repository |
no test coverage detected