fix(git): remove --diff-filter=d to include deleted files in diffs
This commit is contained in:
+6
-6
@@ -41,16 +41,16 @@ export async function getGitDiff(cwd: string, stagedOnly = false): Promise<strin
|
|||||||
let diff = ""
|
let diff = ""
|
||||||
|
|
||||||
if (await hasCommits(cwd)) {
|
if (await hasCommits(cwd)) {
|
||||||
const { stdout: staged } = await execAsync("git --no-pager diff --staged --diff-filter=d", { cwd })
|
const { stdout: staged } = await execAsync("git --no-pager diff --staged", { cwd })
|
||||||
diff = staged.trim()
|
diff = staged.trim()
|
||||||
|
|
||||||
if (!stagedOnly && !diff) {
|
if (!stagedOnly && !diff) {
|
||||||
const { stdout: unstaged } = await execAsync("git --no-pager diff HEAD --diff-filter=d", { cwd })
|
const { stdout: unstaged } = await execAsync("git --no-pager diff HEAD", { cwd })
|
||||||
diff = unstaged.trim()
|
diff = unstaged.trim()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// First commit — no HEAD exists yet
|
// First commit — no HEAD exists yet
|
||||||
const { stdout: cached } = await execAsync("git --no-pager diff --cached --diff-filter=d", { cwd })
|
const { stdout: cached } = await execAsync("git --no-pager diff --cached", { cwd })
|
||||||
diff = cached.trim()
|
diff = cached.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ export async function getGitContext(cwd: string): Promise<{ diff: string; stat:
|
|||||||
let includeUntracked = false
|
let includeUntracked = false
|
||||||
|
|
||||||
if (await hasCommits(cwd)) {
|
if (await hasCommits(cwd)) {
|
||||||
const { stdout: stagedDiff } = await execAsync("git --no-pager diff --staged --diff-filter=d", { cwd })
|
const { stdout: stagedDiff } = await execAsync("git --no-pager diff --staged", { cwd })
|
||||||
diff = stagedDiff.trim()
|
diff = stagedDiff.trim()
|
||||||
|
|
||||||
if (diff) {
|
if (diff) {
|
||||||
@@ -101,7 +101,7 @@ export async function getGitContext(cwd: string): Promise<{ diff: string; stat:
|
|||||||
stat = stagedStat.trim()
|
stat = stagedStat.trim()
|
||||||
} else {
|
} else {
|
||||||
includeUntracked = true
|
includeUntracked = true
|
||||||
const { stdout: allDiff } = await execAsync("git --no-pager diff HEAD --diff-filter=d", { cwd })
|
const { stdout: allDiff } = await execAsync("git --no-pager diff HEAD", { cwd })
|
||||||
diff = allDiff.trim()
|
diff = allDiff.trim()
|
||||||
const { stdout: allStat } = await execAsync("git --no-pager diff HEAD --name-status", { cwd })
|
const { stdout: allStat } = await execAsync("git --no-pager diff HEAD --name-status", { cwd })
|
||||||
stat = allStat.trim()
|
stat = allStat.trim()
|
||||||
@@ -109,7 +109,7 @@ export async function getGitContext(cwd: string): Promise<{ diff: string; stat:
|
|||||||
} else {
|
} else {
|
||||||
// First commit — no HEAD exists yet
|
// First commit — no HEAD exists yet
|
||||||
includeUntracked = true
|
includeUntracked = true
|
||||||
const { stdout: cachedDiff } = await execAsync("git --no-pager diff --cached --diff-filter=d", { cwd })
|
const { stdout: cachedDiff } = await execAsync("git --no-pager diff --cached", { cwd })
|
||||||
diff = cachedDiff.trim()
|
diff = cachedDiff.trim()
|
||||||
const { stdout: cachedStat } = await execAsync("git --no-pager diff --cached --name-status", { cwd })
|
const { stdout: cachedStat } = await execAsync("git --no-pager diff --cached --name-status", { cwd })
|
||||||
stat = cachedStat.trim()
|
stat = cachedStat.trim()
|
||||||
|
|||||||
Reference in New Issue
Block a user