git add (use "." for all)
(opts: { filepath: string; dir?: string })
| 128 | |
| 129 | /** git add <filepath> (use "." for all) */ |
| 130 | async add(opts: { filepath: string; dir?: string }) { |
| 131 | const d = resolveDir(opts.dir); |
| 132 | |
| 133 | if (opts.filepath === ".") { |
| 134 | // Stage all changes |
| 135 | const matrix = await git.statusMatrix({ fs, dir: d }); |
| 136 | for (const [filepath, head, workdir, stage] of matrix) { |
| 137 | const key = `${head}${workdir}${stage}`; |
| 138 | if (key === "111") continue; // unmodified |
| 139 | |
| 140 | if (workdir === 0) { |
| 141 | // Deleted |
| 142 | await git.remove({ fs, dir: d, filepath: filepath as string }); |
| 143 | } else { |
| 144 | await git.add({ fs, dir: d, filepath: filepath as string }); |
| 145 | } |
| 146 | } |
| 147 | return { added: "." }; |
| 148 | } |
| 149 | |
| 150 | await git.add({ fs, dir: d, filepath: opts.filepath }); |
| 151 | return { added: opts.filepath }; |
| 152 | }, |
| 153 | |
| 154 | /** git rm <filepath> */ |
| 155 | async rm(opts: { filepath: string; dir?: string }) { |
nothing calls this directly
no test coverage detected