fix: improve git diff --no-index error handling
Check exitCode === 1 instead of message content, as git diff --no-index returns exit code 1 when differences exist (which is expected behavior, not an error). Amp-Thread-ID: https://ampcode.com/threads/T-019c0a9a-b26b-7719-9718-04185371eb9c Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -428,7 +428,8 @@ export async function getDiff(directory, { path, staged = false, contextLines =
|
|||||||
const noIndexDiff = await git.raw(noIndexArgs);
|
const noIndexDiff = await git.raw(noIndexArgs);
|
||||||
return noIndexDiff;
|
return noIndexDiff;
|
||||||
} catch (noIndexError) {
|
} catch (noIndexError) {
|
||||||
if (noIndexError.message && noIndexError.message.includes('diff --git')) {
|
// git diff --no-index returns exit code 1 when differences exist (not a real error)
|
||||||
|
if (noIndexError.exitCode === 1 && noIndexError.message) {
|
||||||
return noIndexError.message;
|
return noIndexError.message;
|
||||||
}
|
}
|
||||||
throw noIndexError;
|
throw noIndexError;
|
||||||
|
|||||||
Reference in New Issue
Block a user