( client: GitClient, args: string[], input: GitCliInput, )
| 540 | // --------------------------------------------------------------- |
| 541 | |
| 542 | async function runAdd( |
| 543 | client: GitClient, |
| 544 | args: string[], |
| 545 | input: GitCliInput, |
| 546 | ): Promise<GitCliResult> { |
| 547 | // `git add [-A|--all] [--force] <pathspec>...` |
| 548 | const parsed = parseFlags(args, { |
| 549 | force: { kind: "bool", alias: ["f"] }, |
| 550 | all: { kind: "bool", alias: ["A"] }, |
| 551 | }); |
| 552 | if ("error" in parsed) { |
| 553 | return { stdout: "", stderr: `git add: ${parsed.error}\n`, exitCode: 129 }; |
| 554 | } |
| 555 | const all = parsed.flags.all === true; |
| 556 | // `-A` stages the whole tree and needs no pathspec; without it a |
| 557 | // missing pathspec is the same no-op error real git prints. |
| 558 | if (!all && parsed.positional.length === 0) { |
| 559 | return { stdout: "", stderr: "git add: nothing specified, nothing added.\n", exitCode: 129 }; |
| 560 | } |
| 561 | const dir = resolveDir(undefined, input.cwd); |
| 562 | try { |
| 563 | await client.add({ |
| 564 | dir, |
| 565 | paths: all ? [] : parsed.positional, |
| 566 | all, |
| 567 | force: parsed.flags.force === true, |
| 568 | }); |
| 569 | } catch (cause) { |
| 570 | return mapGitError("add", cause); |
| 571 | } |
| 572 | return { stdout: "", stderr: "", exitCode: 0 }; |
| 573 | } |
| 574 | |
| 575 | // --------------------------------------------------------------- |
| 576 | // rm |
no test coverage detected