( repository: Repository, remote: IRemote | null, progressCallback: ((progress: T) => void) | undefined, progressKind: T['kind'], title: string, targetOrRemote: string, allowFileProtocol: boolean )
| 27 | * @param allowFileProtocol - Whether to allow file:// protocol for submodules |
| 28 | */ |
| 29 | export async function updateSubmodulesAfterOperation<T extends Progress>( |
| 30 | repository: Repository, |
| 31 | remote: IRemote | null, |
| 32 | progressCallback: ((progress: T) => void) | undefined, |
| 33 | progressKind: T['kind'], |
| 34 | title: string, |
| 35 | targetOrRemote: string, |
| 36 | allowFileProtocol: boolean |
| 37 | ): Promise<void> { |
| 38 | const opts: IGitStringExecutionOptions = { |
| 39 | env: await envForRemoteOperation( |
| 40 | getFallbackUrlForProxyResolve(repository, remote) |
| 41 | ), |
| 42 | expectedErrors: AuthenticationErrors, |
| 43 | } |
| 44 | |
| 45 | const args = [ |
| 46 | ...(allowFileProtocol ? ['-c', 'protocol.file.allow=always'] : []), |
| 47 | 'submodule', |
| 48 | 'update', |
| 49 | '--init', |
| 50 | '--recursive', |
| 51 | ] |
| 52 | |
| 53 | if (!progressCallback) { |
| 54 | await git(args, repository.path, 'updateSubmodules', opts) |
| 55 | return |
| 56 | } |
| 57 | |
| 58 | // Initial progress |
| 59 | progressCallback({ |
| 60 | kind: progressKind, |
| 61 | title, |
| 62 | description: 'Updating submodules', |
| 63 | value: 0, |
| 64 | // Add the target or remote field based on the progress kind |
| 65 | ...(progressKind === 'checkout' |
| 66 | ? { target: targetOrRemote } |
| 67 | : { remote: targetOrRemote }), |
| 68 | } as T) |
| 69 | |
| 70 | let submoduleEventCount = 0 |
| 71 | |
| 72 | const progressOpts = await executionOptionsWithProgress( |
| 73 | { ...opts, trackLFSProgress: true }, |
| 74 | { |
| 75 | parse(line: string): IGitOutput { |
| 76 | if ( |
| 77 | line.match(/^Submodule path (.)+?: checked out /) || |
| 78 | line.startsWith('Cloning into ') |
| 79 | ) { |
| 80 | submoduleEventCount += 1 |
| 81 | } |
| 82 | |
| 83 | return { |
| 84 | kind: 'context', |
| 85 | text: `Updating submodules: ${line}`, |
| 86 | // Math taken from https://math.stackexchange.com/a/2323106 |
no test coverage detected