Git - wire up event for changing artifact groups (#274261)

* Git - wire up event for changing artifact groups

* Remove code that was commented out

* Swap code order

* Dispose listener

* Dispose event emitter as well
This commit is contained in:
Ladislau Szomoru
2025-10-31 08:24:31 +00:00
committed by GitHub
parent 2b76aa1113
commit cf34c7541c
8 changed files with 77 additions and 44 deletions

View File

@@ -8,8 +8,8 @@ import { dispose, IDisposable } from './util';
import { Repository } from './repository';
export class GitArtifactProvider implements SourceControlArtifactProvider, IDisposable {
private readonly _onDidChangeArtifacts = new EventEmitter<string>();
readonly onDidChangeArtifacts: Event<string> = this._onDidChangeArtifacts.event;
private readonly _onDidChangeArtifacts = new EventEmitter<string[]>();
readonly onDidChangeArtifacts: Event<string[]> = this._onDidChangeArtifacts.event;
private readonly _groups: SourceControlArtifactGroup[];
private readonly _disposables: Disposable[] = [];
@@ -24,6 +24,18 @@ export class GitArtifactProvider implements SourceControlArtifactProvider, IDisp
];
this._disposables.push(this._onDidChangeArtifacts);
this._disposables.push(repository.historyProvider.onDidChangeHistoryItemRefs(e => {
const groups = new Set<string>();
for (const ref of e.added.concat(e.modified).concat(e.removed)) {
if (ref.id.startsWith('refs/heads/')) {
groups.add('branches');
} else if (ref.id.startsWith('refs/tags/')) {
groups.add('tags');
}
}
this._onDidChangeArtifacts.fire(Array.from(groups));
}));
}
provideArtifactGroups(): SourceControlArtifactGroup[] {