fix(git): handle untracked files in collectDiffs for commit message generation
Amp-Thread-ID: https://ampcode.com/threads/T-019c0a87-5323-7098-bea3-a1fc7cd43c18 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -424,8 +424,15 @@ export async function getDiff(directory, { path, staged = false, contextLines =
|
|||||||
noIndexArgs.push(`-U${Math.max(0, contextLines)}`);
|
noIndexArgs.push(`-U${Math.max(0, contextLines)}`);
|
||||||
}
|
}
|
||||||
noIndexArgs.push('--no-index', '--', '/dev/null', path);
|
noIndexArgs.push('--no-index', '--', '/dev/null', path);
|
||||||
const noIndexDiff = await git.raw(noIndexArgs);
|
try {
|
||||||
return noIndexDiff;
|
const noIndexDiff = await git.raw(noIndexArgs);
|
||||||
|
return noIndexDiff;
|
||||||
|
} catch (noIndexError) {
|
||||||
|
if (noIndexError.message && noIndexError.message.includes('diff --git')) {
|
||||||
|
return noIndexError.message;
|
||||||
|
}
|
||||||
|
throw noIndexError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to get Git diff:', error);
|
console.error('Failed to get Git diff:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user