Git - tweak copilot worktree folder detection (#299147)

* Git - tweak copilot worktree folder detection

* Pull request feedback
This commit is contained in:
Ladislau Szomoru
2026-03-04 09:58:25 +01:00
committed by GitHub
parent b5a312a098
commit 4ff01e687e
3 changed files with 8 additions and 14 deletions

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { LogOutputChannel, SourceControlArtifactProvider, SourceControlArtifactGroup, SourceControlArtifact, Event, EventEmitter, ThemeIcon, l10n, workspace, Uri, Disposable, Command } from 'vscode';
import { coalesce, dispose, filterEvent, IDisposable, isCopilotWorktree } from './util';
import { coalesce, dispose, filterEvent, IDisposable, isCopilotWorktreeFolder } from './util';
import { Repository } from './repository';
import type { Ref, Worktree } from './api/git';
import { RefType } from './api/git.constants';
@@ -178,7 +178,7 @@ export class GitArtifactProvider implements SourceControlArtifactProvider, IDisp
]).join(' \u2022 '),
icon: w.main
? new ThemeIcon('repo')
: isCopilotWorktree(w.path)
: isCopilotWorktreeFolder(w.path)
? new ThemeIcon('chat-sparkle')
: new ThemeIcon('worktree')
}));

View File

@@ -25,7 +25,7 @@ import { IPushErrorHandlerRegistry } from './pushError';
import { IRemoteSourcePublisherRegistry } from './remotePublisher';
import { StatusBarCommands } from './statusbar';
import { toGitUri } from './uri';
import { anyEvent, combinedDisposable, debounceEvent, dispose, EmptyDisposable, eventToPromise, filterEvent, find, getCommitShortHash, IDisposable, isCopilotWorktree, isDescendant, isLinuxSnap, isRemote, isWindows, Limiter, onceEvent, pathEquals, relativePath } from './util';
import { anyEvent, combinedDisposable, debounceEvent, dispose, EmptyDisposable, eventToPromise, filterEvent, find, getCommitShortHash, IDisposable, isCopilotWorktreeFolder, isDescendant, isLinuxSnap, isRemote, isWindows, Limiter, onceEvent, pathEquals, relativePath } from './util';
import { IFileWatcher, watch } from './watch';
import { ISourceControlHistoryItemDetailsProviderRegistry } from './historyItemDetailsProvider';
import { GitArtifactProvider } from './artifactProvider';
@@ -954,7 +954,7 @@ export class Repository implements Disposable {
const icon = repository.kind === 'submodule'
? new ThemeIcon('archive')
: repository.kind === 'worktree'
? isCopilotWorktree(repository.root)
? isCopilotWorktreeFolder(repository.root)
? new ThemeIcon('chat-sparkle')
: new ThemeIcon('worktree')
: new ThemeIcon('repo');
@@ -967,7 +967,7 @@ export class Repository implements Disposable {
// from the Repositories view.
this._isHidden = workspace.workspaceFolders === undefined ||
(repository.kind === 'worktree' &&
isCopilotWorktree(repository.root) && parent !== undefined);
isCopilotWorktreeFolder(repository.root) && parent !== undefined);
const root = Uri.file(repository.root);
this._sourceControl = scm.createSourceControl('git', 'Git', root, icon, this._isHidden, parent);

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Event, Disposable, EventEmitter, SourceControlHistoryItemRef, l10n, workspace, Uri, DiagnosticSeverity, env, SourceControlHistoryItem } from 'vscode';
import { dirname, normalize, sep, relative } from 'path';
import { basename, dirname, normalize, sep, relative } from 'path';
import { Readable } from 'stream';
import { promises as fs, createReadStream } from 'fs';
import byline from 'byline';
@@ -867,12 +867,6 @@ export function getStashDescription(stash: Stash): string | undefined {
return descriptionSegments.join(' \u2022 ');
}
export const CopilotWorktreeBranchPrefix = 'copilot-worktree-';
export function isCopilotWorktree(path: string): boolean {
const lastSepIndex = path.lastIndexOf(sep);
return lastSepIndex !== -1
? path.substring(lastSepIndex + 1).startsWith(CopilotWorktreeBranchPrefix)
: path.startsWith(CopilotWorktreeBranchPrefix);
export function isCopilotWorktreeFolder(path: string): boolean {
return basename(path).startsWith('copilot-');
}