mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-14 17:25:28 -05:00
Defaults stashes format to ${filePath}
Adds message when there are no stashes Cleans up the stash explorer
This commit is contained in:
@@ -294,7 +294,7 @@ GitLens is highly customizable and provides many configuration settings to allow
|
||||
|Name | Description
|
||||
|-----|------------
|
||||
|`gitlens.stashExplorer.stashFormat`|Specifies the format of stashed changes in the `Git Stashes` explorer <br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
|
||||
|`gitlens.stashExplorer.stashFileFormat`|Specifies the format of a stashed file in the `Git Stashes` explorer <br />Available tokens<br /> ${file} - file name<br /> ${path} - file path
|
||||
|`gitlens.stashExplorer.stashFileFormat`|Specifies the format of a stashed file in the `Git Stashes` explorer <br />Available tokens<br /> ${file} - file name<br /> ${filePath} - file name and path<br /> ${path} - file path
|
||||
|
||||
### Status Bar Settings
|
||||
|
||||
|
||||
@@ -420,8 +420,8 @@
|
||||
},
|
||||
"gitlens.stashExplorer.stashFileFormat": {
|
||||
"type": "string",
|
||||
"default": "${file} \u00a0\u2022\u00a0 ${path}",
|
||||
"description": "Specifies the format of a stashed file in the `Git Stashes` explorer\nAvailable tokens\n ${file} - file name\n ${path} - file path"
|
||||
"default": "${filePath}",
|
||||
"description": "Specifies the format of a stashed file in the `Git Stashes` explorer\nAvailable tokens\n ${file} - file name\n ${filePath} - file name and path\n ${path} - file path"
|
||||
},
|
||||
"gitlens.statusBar.enabled": {
|
||||
"type": "boolean",
|
||||
@@ -1161,11 +1161,12 @@
|
||||
},
|
||||
{
|
||||
"command": "gitlens.gitExplorer.refresh",
|
||||
"when": "gitlens:enabled"
|
||||
"when": "false"
|
||||
},
|
||||
},
|
||||
{
|
||||
"command": "gitlens.stashExplorer.refresh",
|
||||
"when": "gitlens:enabled"
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "gitlens.stashExplorer.openChanges",
|
||||
|
||||
@@ -6,13 +6,17 @@ import { GitService, GitUri } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import { OpenInRemoteCommandArgs } from './openInRemote';
|
||||
|
||||
export interface OpenFileInRemoteCommandArgs {
|
||||
range?: boolean;
|
||||
}
|
||||
|
||||
export class OpenFileInRemoteCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.OpenFileInRemote);
|
||||
}
|
||||
|
||||
async execute(editor?: TextEditor, uri?: Uri) {
|
||||
async execute(editor?: TextEditor, uri?: Uri, args: OpenFileInRemoteCommandArgs = { range: true }) {
|
||||
uri = getCommandUri(uri, editor);
|
||||
if (uri === undefined) return undefined;
|
||||
|
||||
@@ -23,7 +27,9 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
|
||||
|
||||
try {
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(gitUri.repoPath), _ => _.url, _ => !!_.provider);
|
||||
const range = editor === undefined ? undefined : new Range(editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 }));
|
||||
const range = (args.range && editor !== undefined)
|
||||
? new Range(editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 }))
|
||||
: undefined;
|
||||
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, {
|
||||
resource: {
|
||||
|
||||
@@ -297,14 +297,12 @@ export interface IConfig {
|
||||
defaultDateFormat: string | null;
|
||||
|
||||
gitExplorer: {
|
||||
enabled: boolean;
|
||||
commitFormat: string;
|
||||
commitFileFormat: string;
|
||||
// dateFormat: string | null;
|
||||
};
|
||||
|
||||
stashExplorer: {
|
||||
enabled: boolean;
|
||||
stashFormat: string;
|
||||
stashFileFormat: string;
|
||||
// dateFormat: string | null;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
// import { Functions } from '../system';
|
||||
import { commands, Event, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, Uri } from 'vscode';
|
||||
import { Commands, DiffWithPreviousCommandArgs, openEditor } from '../commands';
|
||||
import { Commands, DiffWithPreviousCommandArgs, openEditor, OpenFileInRemoteCommandArgs } from '../commands';
|
||||
import { ExplorerNode, StashCommitNode, StashNode } from './explorerNodes';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
|
||||
@@ -10,7 +10,6 @@ export * from './explorerNodes';
|
||||
export class StashExplorer implements TreeDataProvider<ExplorerNode> {
|
||||
|
||||
private _node: ExplorerNode;
|
||||
// private _refreshDebounced: () => void;
|
||||
|
||||
private _onDidChangeTreeData = new EventEmitter<ExplorerNode>();
|
||||
public get onDidChangeTreeData(): Event<ExplorerNode> {
|
||||
@@ -24,28 +23,12 @@ export class StashExplorer implements TreeDataProvider<ExplorerNode> {
|
||||
commands.registerCommand('gitlens.stashExplorer.openStashedFile', this.openStashedFile, this);
|
||||
commands.registerCommand('gitlens.stashExplorer.openFileInRemote', this.openFileInRemote, this);
|
||||
|
||||
context.subscriptions.push(this.git.onDidChangeRepo(reasons => {
|
||||
if (!reasons.includes('stash')) return;
|
||||
context.subscriptions.push(this.git.onDidChangeRepo(this.onRepoChanged, this));
|
||||
|
||||
this.refresh();
|
||||
}, this));
|
||||
|
||||
// this._refreshDebounced = Functions.debounce(this.refresh.bind(this), 250);
|
||||
|
||||
// const editor = window.activeTextEditor;
|
||||
|
||||
// const uri = (editor !== undefined && editor.document !== undefined)
|
||||
// ? new GitUri(editor.document.uri, { repoPath: git.repoPath, fileName: editor.document.uri.fsPath })
|
||||
// : new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
|
||||
|
||||
const uri = new GitUri(Uri.file(git.repoPath), { repoPath: git.repoPath, fileName: git.repoPath });
|
||||
this._node = new StashNode(uri, this.context, this.git);
|
||||
this._node = this.getRootNode();
|
||||
}
|
||||
|
||||
async getTreeItem(node: ExplorerNode): Promise<TreeItem> {
|
||||
// if (node.onDidChangeTreeData !== undefined) {
|
||||
// node.onDidChangeTreeData(() => setTimeout(this._refreshDebounced, 1));
|
||||
// }
|
||||
return node.getTreeItem();
|
||||
}
|
||||
|
||||
@@ -54,10 +37,16 @@ export class StashExplorer implements TreeDataProvider<ExplorerNode> {
|
||||
return node.getChildren();
|
||||
}
|
||||
|
||||
// update(uri: GitUri) {
|
||||
// this._node = new StashNode(uri, this.context, this.git);
|
||||
// this.refresh();
|
||||
// }
|
||||
private getRootNode(): ExplorerNode {
|
||||
const uri = new GitUri(Uri.file(this.git.repoPath), { repoPath: this.git.repoPath, fileName: this.git.repoPath });
|
||||
return new StashNode(uri, this.context, this.git);
|
||||
}
|
||||
|
||||
private onRepoChanged(reasons: ('stash' | 'unknown')[]) {
|
||||
if (!reasons.includes('stash')) return;
|
||||
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
refresh() {
|
||||
this._onDidChangeTreeData.fire();
|
||||
@@ -81,6 +70,6 @@ export class StashExplorer implements TreeDataProvider<ExplorerNode> {
|
||||
}
|
||||
|
||||
private openFileInRemote(node: StashCommitNode) {
|
||||
return commands.executeCommand(Commands.OpenFileInRemote, node.commit.previousUri);
|
||||
return commands.executeCommand(Commands.OpenFileInRemote, node.commit.uri, { range: false } as OpenFileInRemoteCommandArgs);
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,9 @@ export class StashNode extends ExplorerNode {
|
||||
super(uri);
|
||||
}
|
||||
|
||||
async getChildren(): Promise<StashCommitNode[]> {
|
||||
async getChildren(): Promise<ExplorerNode[]> {
|
||||
const stash = await this.git.getStashList(this.uri.repoPath!);
|
||||
if (stash === undefined) return [];
|
||||
if (stash === undefined) return [new TextExplorerNode('No stashed changes')];
|
||||
|
||||
return [...Iterables.map(stash.commits.values(), c => new StashCommitNode(c, this.context, this.git))];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user