refactor(tui): remove unused revert diff parser (#39963)
Co-authored-by: Kit Langton <kit.langton@gmail.com>
This commit is contained in:
parent
cfcd8de62a
commit
8285a18f18
4 changed files with 0 additions and 55 deletions
1
bun.lock
1
bun.lock
|
|
@ -88,7 +88,6 @@
|
||||||
"@tanstack/solid-query": "5.91.4",
|
"@tanstack/solid-query": "5.91.4",
|
||||||
"@tanstack/solid-virtual": "catalog:",
|
"@tanstack/solid-virtual": "catalog:",
|
||||||
"@thisbeyond/solid-dnd": "0.7.5",
|
"@thisbeyond/solid-dnd": "0.7.5",
|
||||||
"diff": "catalog:",
|
|
||||||
"effect": "catalog:",
|
"effect": "catalog:",
|
||||||
"fuzzysort": "catalog:",
|
"fuzzysort": "catalog:",
|
||||||
"ghostty-web": "github:anomalyco/ghostty-web#83c0a07b8628b748aed073b232cb4b52a6ca11c1",
|
"ghostty-web": "github:anomalyco/ghostty-web#83c0a07b8628b748aed073b232cb4b52a6ca11c1",
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@
|
||||||
"@opentui/solid": "catalog:",
|
"@opentui/solid": "catalog:",
|
||||||
"@solid-primitives/event-bus": "1.1.2",
|
"@solid-primitives/event-bus": "1.1.2",
|
||||||
"clipboardy": "4.0.0",
|
"clipboardy": "4.0.0",
|
||||||
"diff": "catalog:",
|
|
||||||
"effect": "catalog:",
|
"effect": "catalog:",
|
||||||
"fuzzysort": "catalog:",
|
"fuzzysort": "catalog:",
|
||||||
"get-east-asian-width": "catalog:",
|
"get-east-asian-width": "catalog:",
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
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 []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
import { describe, expect, test } from "bun:test"
|
|
||||||
import { getRevertDiffFiles } from "../../src/util/revert-diff"
|
|
||||||
|
|
||||||
describe("revert diff", () => {
|
|
||||||
test("prefers the actual file path over /dev/null for added and deleted files", () => {
|
|
||||||
const files = getRevertDiffFiles(`diff --git a/new.txt b/new.txt
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..3b18e51
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/new.txt
|
|
||||||
@@ -0,0 +1 @@
|
|
||||||
+new content
|
|
||||||
diff --git a/old.txt b/old.txt
|
|
||||||
deleted file mode 100644
|
|
||||||
index 3b18e51..0000000
|
|
||||||
--- a/old.txt
|
|
||||||
+++ /dev/null
|
|
||||||
@@ -1 +0,0 @@
|
|
||||||
-old content
|
|
||||||
`)
|
|
||||||
|
|
||||||
expect(files).toEqual([
|
|
||||||
{
|
|
||||||
filename: "new.txt",
|
|
||||||
additions: 1,
|
|
||||||
deletions: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
filename: "old.txt",
|
|
||||||
additions: 0,
|
|
||||||
deletions: 1,
|
|
||||||
},
|
|
||||||
])
|
|
||||||
})
|
|
||||||
})
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue