SCM - do not group stashes in folders (#279601)

This commit is contained in:
Ladislau Szomoru
2025-11-26 14:55:22 +00:00
committed by GitHub
parent c1253353ff
commit 3bd3345259
5 changed files with 33 additions and 15 deletions

View File

@@ -82,9 +82,9 @@ export class GitArtifactProvider implements SourceControlArtifactProvider, IDisp
private readonly logger: LogOutputChannel
) {
this._groups = [
{ id: 'branches', name: l10n.t('Branches'), icon: new ThemeIcon('git-branch') },
{ id: 'stashes', name: l10n.t('Stashes'), icon: new ThemeIcon('git-stash') },
{ id: 'tags', name: l10n.t('Tags'), icon: new ThemeIcon('tag') }
{ id: 'branches', name: l10n.t('Branches'), icon: new ThemeIcon('git-branch'), supportsFolders: true },
{ id: 'stashes', name: l10n.t('Stashes'), icon: new ThemeIcon('git-stash'), supportsFolders: false },
{ id: 'tags', name: l10n.t('Tags'), icon: new ThemeIcon('tag'), supportsFolders: true }
];
this._disposables.push(this._onDidChangeArtifacts);

View File

@@ -1752,6 +1752,7 @@ export interface SCMArtifactGroupDto {
readonly id: string;
readonly name: string;
readonly icon?: UriComponents | { light: UriComponents; dark: UriComponents } | ThemeIcon;
readonly supportsFolders?: boolean;
}
export interface SCMArtifactDto {

View File

@@ -174,6 +174,7 @@ class ArtifactRenderer implements ICompressibleTreeRenderer<SCMArtifactTreeEleme
// Label
if (isSCMArtifactTreeElement(artifactOrFolder)) {
// Artifact
const artifactGroup = artifactOrFolder.group;
const artifact = artifactOrFolder.artifact;
const artifactIcon = artifact.icon ?? artifactOrFolder.group.icon;
@@ -181,7 +182,9 @@ class ArtifactRenderer implements ICompressibleTreeRenderer<SCMArtifactTreeEleme
? `icon ${ThemeIcon.asClassName(artifactIcon)}`
: '';
const artifactLabel = artifact.name.split('/').pop() ?? artifact.name;
const artifactLabel = artifactGroup.supportsFolders
? artifact.name.split('/').pop() ?? artifact.name
: artifact.name;
templateData.label.setLabel(artifactLabel, artifact.description);
} else if (isSCMArtifactNode(artifactOrFolder)) {
// Folder
@@ -294,24 +297,36 @@ class RepositoryTreeDataSource extends Disposable implements IAsyncDataSource<IS
const repository = inputOrElement.repository;
const artifacts = await repository.provider.artifactProvider.get()?.provideArtifacts(inputOrElement.artifactGroup.id) ?? [];
// Create resource tree for artifacts
const artifactsTree = new ResourceTree<SCMArtifactTreeElement, SCMArtifactGroupTreeElement>(inputOrElement);
for (const artifact of artifacts) {
artifactsTree.add(URI.from({
scheme: 'scm-artifact', path: artifact.name
}), {
if (inputOrElement.artifactGroup.supportsFolders) {
// Resource tree for artifacts
const artifactsTree = new ResourceTree<SCMArtifactTreeElement, SCMArtifactGroupTreeElement>(inputOrElement);
for (const artifact of artifacts) {
artifactsTree.add(URI.from({
scheme: 'scm-artifact', path: artifact.name
}), {
repository,
group: inputOrElement.artifactGroup,
artifact,
type: 'artifact'
});
}
return Iterable.map(artifactsTree.root.children, node => node.element ?? node);
}
// Flat list of artifacts
return artifacts.map(artifact => (
{
repository,
group: inputOrElement.artifactGroup,
artifact,
type: 'artifact'
});
}
return Iterable.map(artifactsTree.root.children, node => node.element ?? node);
} satisfies SCMArtifactTreeElement
));
} else if (isSCMArtifactNode(inputOrElement)) {
return Iterable.map(inputOrElement.children,
node => node.element && node.childrenCount === 0 ? node.element : node);
} else if (isSCMArtifactTreeElement(inputOrElement)) { }
}
return [];
}

View File

@@ -18,6 +18,7 @@ export interface ISCMArtifactGroup {
readonly id: string;
readonly name: string;
readonly icon?: URI | { light: URI; dark: URI } | ThemeIcon;
readonly supportsFolders?: boolean;
}
export interface ISCMArtifact {

View File

@@ -21,6 +21,7 @@ declare module 'vscode' {
readonly id: string;
readonly name: string;
readonly icon?: IconPath;
readonly supportsFolders?: boolean;
}
export interface SourceControlArtifact {