( git: IsomorphicGitDiffClient, fs: object, dir: string, oid: string, filepath: string, cache: object | undefined, )
| 285 | } |
| 286 | |
| 287 | async function readBlobAsText( |
| 288 | git: IsomorphicGitDiffClient, |
| 289 | fs: object, |
| 290 | dir: string, |
| 291 | oid: string, |
| 292 | filepath: string, |
| 293 | cache: object | undefined, |
| 294 | ): Promise<string> { |
| 295 | try { |
| 296 | const { blob } = await git.readBlob({ fs, dir, oid, filepath, cache }); |
| 297 | // Best-effort UTF-8 decode. A real diff tool would skip |
| 298 | // binaries entirely; for the general case here a noisy diff |
| 299 | // beats a thrown error. |
| 300 | return new TextDecoder("utf-8", { fatal: false, ignoreBOM: false }).decode(blob); |
| 301 | } catch { |
| 302 | return ""; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | async function readWorkdirAsText( |
| 307 | readFile: ReadFileFn, |
no test coverage detected