Buckets:
| import { parsePatch } from "diff" | |
| export function getRevertDiffFiles(diffText: string) { | |
| if (!diffText) return [] | |
| try { | |
| return parsePatch(diffText).map((patch) => { | |
| const filename = [patch.newFileName, patch.oldFileName].find((item) => item && item !== "/dev/null") ?? "unknown" | |
| return { | |
| filename: filename.replace(/^[ab]\//, ""), | |
| additions: patch.hunks.reduce((sum, hunk) => sum + hunk.lines.filter((line) => line.startsWith("+")).length, 0), | |
| deletions: patch.hunks.reduce((sum, hunk) => sum + hunk.lines.filter((line) => line.startsWith("-")).length, 0), | |
| } | |
| }) | |
| } catch { | |
| return [] | |
| } | |
| } | |
Xet Storage Details
- Size:
- 650 Bytes
- Xet hash:
- c291939b4a2de2eb50774b86ee367f053f7a636f0597986e9e976d8bb76538aa
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.