(opts: ResetWithDeps, dir: string, ref: string)
| 164 | } |
| 165 | |
| 166 | async function hardReset(opts: ResetWithDeps, dir: string, ref: string): Promise<void> { |
| 167 | // Real `git reset --hard <ref>` moves the current branch to the |
| 168 | // target commit when HEAD is symbolic, then rewrites the index |
| 169 | // and work tree. A plain checkout of a resolved oid would leave |
| 170 | // HEAD detached, so update the branch ref first and then |
| 171 | // checkout that branch name to materialize the tree. |
| 172 | const oid = await opts.git.resolveRef({ fs: opts.fs, dir, ref }); |
| 173 | const branch = await opts.git.currentBranch({ fs: opts.fs, dir, fullname: true }); |
| 174 | if (branch) { |
| 175 | await opts.git.writeRef({ fs: opts.fs, dir, ref: branch, value: oid, force: true }); |
| 176 | await opts.git.checkout({ fs: opts.fs, dir, ref: branch, force: true, cache: opts.cache }); |
| 177 | return; |
| 178 | } |
| 179 | await opts.git.checkout({ fs: opts.fs, dir, ref: oid, force: true, cache: opts.cache }); |
| 180 | } |
| 181 | |
| 182 | async function stagedPaths(opts: ResetWithDeps, dir: string): Promise<string[]> { |
| 183 | const matrix = await opts.git.statusMatrix({ fs: opts.fs, dir, cache: opts.cache }); |
no test coverage detected