Skip to content

Commit 2dc08b1

Browse files
committed
Background - return worktree changes for all repositories (#3365)
1 parent 503b2ec commit 2dc08b1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/extension/chatSessions/vscode-node/chatSessionWorktreeServiceImpl.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ILogService } from '../../../platform/log/common/logService';
1313
import { IWorkspaceService } from '../../../platform/workspace/common/workspaceService';
1414
import { Disposable } from '../../../util/vs/base/common/lifecycle';
1515
import * as path from '../../../util/vs/base/common/path';
16-
import { basename, isEqual } from '../../../util/vs/base/common/resources';
16+
import { basename } from '../../../util/vs/base/common/resources';
1717
import { ChatSessionWorktreeData, ChatSessionWorktreeFile, ChatSessionWorktreeProperties, IChatSessionWorktreeService } from '../common/chatSessionWorktreeService';
1818

1919
const CHAT_SESSION_WORKTREE_MEMENTO_KEY = 'github.copilot.cli.sessionWorktrees';
@@ -242,15 +242,6 @@ export class ChatSessionWorktreeService extends Disposable implements IChatSessi
242242
// so we can get them from the main repository or discovered worktree.
243243
await this.gitService.initialize();
244244

245-
// TODO@lszomoru: Remove this change to support welcome view
246-
// Check whether the worktree belongs to any of the discovered repositories
247-
const repository = this.gitService.repositories
248-
.find(r => r.worktrees.some(w => isEqual(vscode.Uri.file(w.path), worktreePath)));
249-
250-
if (!repository) {
251-
return undefined;
252-
}
253-
254245
if (worktreeProperties.autoCommit === false) {
255246
// These changes are staged in the worktree but not yet committed. Since the
256247
// changes are not committed, we need to get them from the worktree repository
@@ -293,6 +284,15 @@ export class ChatSessionWorktreeService extends Disposable implements IChatSessi
293284
return changes;
294285
}
295286

287+
// Open the main repository that contains the worktree. We have to open
288+
// the repository so that we can run do `git diff` against the repository
289+
// to get the committed changes in the worktree branch.
290+
const repository = await this.gitService.getRepository(vscode.Uri.file(worktreeProperties.repositoryPath));
291+
292+
if (!repository) {
293+
return undefined;
294+
}
295+
296296
// These changes are committed in the worktree branch but since they are
297297
// committed we can get the changes from the main repository and we do
298298
// not need to open the worktree repository.

0 commit comments

Comments
 (0)