mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Git - add "Stashes" node to the repositories view (#279400)
* WIP - Initial implementation * Get author and committer date for a stash * Add drop stash command * More cleanup
This commit is contained in:
@@ -4,9 +4,10 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { LogOutputChannel, SourceControlArtifactProvider, SourceControlArtifactGroup, SourceControlArtifact, Event, EventEmitter, ThemeIcon, l10n, workspace, Uri, Disposable } from 'vscode';
|
||||
import { dispose, fromNow, IDisposable } from './util';
|
||||
import { dispose, filterEvent, fromNow, getStashDescription, IDisposable } from './util';
|
||||
import { Repository } from './repository';
|
||||
import { Ref, RefType } from './api/git';
|
||||
import { OperationKind } from './operation';
|
||||
|
||||
function getArtifactDescription(ref: Ref, shortCommitLength: number): string {
|
||||
const segments: string[] = [];
|
||||
@@ -82,6 +83,7 @@ export class GitArtifactProvider implements SourceControlArtifactProvider, IDisp
|
||||
) {
|
||||
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') }
|
||||
];
|
||||
|
||||
@@ -98,6 +100,15 @@ export class GitArtifactProvider implements SourceControlArtifactProvider, IDisp
|
||||
|
||||
this._onDidChangeArtifacts.fire(Array.from(groups));
|
||||
}));
|
||||
|
||||
const onDidRunWriteOperation = filterEvent(
|
||||
repository.onDidRunOperation, e => !e.operation.readOnly);
|
||||
|
||||
this._disposables.push(onDidRunWriteOperation(result => {
|
||||
if (result.operation.kind === OperationKind.Stash) {
|
||||
this._onDidChangeArtifacts.fire(['stashes']);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
provideArtifactGroups(): SourceControlArtifactGroup[] {
|
||||
@@ -133,6 +144,15 @@ export class GitArtifactProvider implements SourceControlArtifactProvider, IDisp
|
||||
? new ThemeIcon('target')
|
||||
: new ThemeIcon('tag')
|
||||
}));
|
||||
} else if (group === 'stashes') {
|
||||
const stashes = await this.repository.getStashes();
|
||||
|
||||
return stashes.map(s => ({
|
||||
id: `stash@{${s.index}}`,
|
||||
name: s.description,
|
||||
description: getStashDescription(s),
|
||||
icon: new ThemeIcon('git-stash')
|
||||
}));
|
||||
}
|
||||
} catch (err) {
|
||||
this.logger.error(`[GitArtifactProvider][provideArtifacts] Error while providing artifacts for group '${group}': `, err);
|
||||
|
||||
Reference in New Issue
Block a user