Git - more cleanup of the history item labels (#216648)

* Git - 💄 history provider cleanup

* Git - more cleanup of the history item labels
This commit is contained in:
Ladislau Szomoru 2024-06-20 01:23:05 +02:00 committed by GitHub
parent f280d9980f
commit eb4092a6de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,6 +32,12 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
}
private historyItemDecorations = new Map<string, FileDecoration>();
private historyItemLabels = new Map<string, string>([
['HEAD -> refs/heads/', 'target'],
['refs/heads/', 'git-branch'],
['refs/remotes/', 'cloud'],
['refs/tags/', 'tag']
]);
private disposables: Disposable[] = [];
@ -262,35 +268,18 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
const labels: SourceControlHistoryItemLabel[] = [];
for (const label of commit.refNames) {
if (label.startsWith('HEAD -> ')) {
labels.push(
{
title: label.substring(19),
icon: new ThemeIcon('git-branch')
}
);
if (!label.startsWith('HEAD -> ') && !refNames.includes(label)) {
continue;
}
if (!refNames.includes(label)) {
continue;
}
if (label.startsWith('refs/tags/')) {
labels.push({
title: label.substring(10),
icon: new ThemeIcon('tag')
});
} else if (label.startsWith('refs/remotes/')) {
labels.push({
title: label.substring(13),
icon: new ThemeIcon('cloud')
});
} else {
labels.push({
title: label.substring(11),
icon: new ThemeIcon('git-branch')
});
for (const [key, value] of this.historyItemLabels) {
if (label.startsWith(key)) {
labels.push({
title: label.substring(key.length),
icon: new ThemeIcon(value)
});
break;
}
}
}