* Create a branch (optionally at a start point) and move HEAD to * it — the shared core of `checkout -b` and `switch -c`. The * branch is created first; only on success does HEAD move, so a * name collision leaves the working tree untouched.
( client: GitClient, dir: string, name: string, startPoint: string | undefined, subcommand: string, )
| 1332 | * name collision leaves the working tree untouched. |
| 1333 | */ |
| 1334 | async function createAndSwitch( |
| 1335 | client: GitClient, |
| 1336 | dir: string, |
| 1337 | name: string, |
| 1338 | startPoint: string | undefined, |
| 1339 | subcommand: string, |
| 1340 | ): Promise<GitCliResult> { |
| 1341 | try { |
| 1342 | await client.branch({ dir, name, startPoint, force: false }); |
| 1343 | } catch (cause) { |
| 1344 | return mapGitError(subcommand, cause); |
| 1345 | } |
| 1346 | try { |
| 1347 | await client.checkout({ dir, ref: name }); |
| 1348 | return { stdout: "", stderr: "", exitCode: 0 }; |
| 1349 | } catch (cause) { |
| 1350 | return mapGitError(subcommand, cause); |
| 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | // --------------------------------------------------------------- |
| 1355 | // fetch |
no test coverage detected