mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-19 22:42:35 +01:00
Agent Host changes for benibenj/agents/log-analysis-error-fix-prioritization-60ed07f4
This commit is contained in:
@@ -1308,7 +1308,9 @@ export function parseUntrackedPaths(output: string | undefined): string[] {
|
||||
* Parses NUL-separated `git status --porcelain=v1 -z --untracked-files=all`
|
||||
* output and returns all changed repo-relative paths. Rename/copy entries
|
||||
* include both the destination and source paths so scoped `git add -A`
|
||||
* stages both sides of the change.
|
||||
* stages both sides of the change. Paths added to the index and then deleted
|
||||
* from the worktree are omitted because they do not exist in either HEAD or
|
||||
* the worktree.
|
||||
*
|
||||
* Exported for tests.
|
||||
*/
|
||||
@@ -1334,7 +1336,10 @@ export function parseChangedPaths(output: string | undefined, includeStatus: (st
|
||||
const path = seg.substring(3);
|
||||
const isRenameOrCopy = status[0] === 'R' || status[1] === 'R' || status[0] === 'C' || status[1] === 'C';
|
||||
if (includeStatus(status)) {
|
||||
addPath(path);
|
||||
const isDeletedIndexAddition = status[1] === 'D' && (status[0] === 'A' || status[0] === 'R' || status[0] === 'C');
|
||||
if (!isDeletedIndexAddition) {
|
||||
addPath(path);
|
||||
}
|
||||
if (isRenameOrCopy) {
|
||||
const sourcePath = segments[++i];
|
||||
if (sourcePath) {
|
||||
|
||||
@@ -310,6 +310,23 @@ suite('AgentHostGitService - computeSessionFileDiffs (real git)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
(hasGit ? test : test.skip)('ignores an index addition deleted from the worktree during temp-index staging', async () => {
|
||||
const fs = await import('fs/promises');
|
||||
const { dir, run } = initRepo();
|
||||
await fs.writeFile(join(dir, 'tracked.txt'), 'tracked\n');
|
||||
run('add', '.');
|
||||
run('commit', '-q', '-m', 'init');
|
||||
|
||||
await fs.writeFile(join(dir, 'deleted-addition.txt'), 'temporary\n');
|
||||
run('add', 'deleted-addition.txt');
|
||||
await fs.unlink(join(dir, 'deleted-addition.txt'));
|
||||
await fs.writeFile(join(dir, 'fresh.txt'), 'fresh\n');
|
||||
|
||||
const result = await svc!.computeSessionFileDiffs(URI.file(dir), { sessionUri: 'copilot:/s' });
|
||||
|
||||
assert.deepStrictEqual(result?.map(diff => URI.parse(diff.after?.uri ?? diff.before!.uri).path.split('/').pop()), ['fresh.txt']);
|
||||
});
|
||||
|
||||
(hasGit && !isWindows ? test : test.skip)('returns undefined when temp-index staging fails', async () => {
|
||||
const fs = await import('fs/promises');
|
||||
const { dir } = initRepo();
|
||||
|
||||
@@ -278,6 +278,9 @@ suite('AgentHostGitService', () => {
|
||||
'renamed-old.txt',
|
||||
' C copied-new.txt',
|
||||
'copied-old.txt',
|
||||
'AD deleted-index-addition.txt',
|
||||
'RD deleted-rename-destination.txt',
|
||||
'rename-source.txt',
|
||||
' M modified.txt',
|
||||
'',
|
||||
].join('\x00');
|
||||
@@ -291,6 +294,7 @@ suite('AgentHostGitService', () => {
|
||||
'renamed-old.txt',
|
||||
'copied-new.txt',
|
||||
'copied-old.txt',
|
||||
'rename-source.txt',
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user