Bläddra i källkod

Adds 'explore repo at' command to revision files

main
Eric Amodio 5 år sedan
förälder
incheckning
2588abb7df
8 ändrade filer med 94 tillägg och 22 borttagningar
  1. +2
    -1
      CHANGELOG.md
  2. +3
    -0
      images/dark/icon-open-folder.svg
  3. +3
    -0
      images/light/icon-open-folder.svg
  4. +31
    -4
      package.json
  5. +1
    -0
      src/commands.ts
  6. +1
    -0
      src/commands/common.ts
  7. +48
    -0
      src/commands/exploreRepoAtRevision.ts
  8. +5
    -17
      src/views/viewCommands.ts

+ 2
- 1
CHANGELOG.md Visa fil

@ -16,7 +16,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds a `gitlens.sortTagsBy` setting to specify how tags are sorted in quick pick menus and views
- Adds last commit date to branches in quick pick menus and views
- Adds ability to copy the selected item's details to the clipboard using the standard copy shortcut key when focused on a GitLens view
- Adds an _Open Revision_ command to the editor toolbar and tabs menu when in the diff editor
- Adds an _Open Revision_ command to the editor toolbar and tabs context menu when a revision file is active in the diff editor
- Adds an _Explore Repository from Here_ command to the editor toolbar and tabs context menu when a revision file is active
- Adds a _Prune_ command to remotes in the _Repositories_ view to prune remote references — closes [#556](https://github.com/eamodio/vscode-gitlens/issues/556) thanks to [PR #815](https://github.com/eamodio/vscode-gitlens/pull/815) by Zach Boyle ([@zaboyle](https://github.com/zaboyle))
- Adds support to use the GitHub avatar (if available) for authors with `@users.noreply.github.com` email addresses — partially addresses [#281](https://github.com/eamodio/vscode-gitlens/issues/281) thanks to [PR #814](https://github.com/eamodio/vscode-gitlens/pull/814) by bolte-17 ([@bolte-17](https://github.com/bolte-17))

+ 3
- 0
images/dark/icon-open-folder.svg Visa fil

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path fill="#C5C5C5" fill-rule="evenodd" d="M13 6V3.5l-.5-.5H6.707l-.853-.854L5.5 2h-5l-.5.5v11l.5.5-.475-.658.071-.214-.071.214L.5 14h12.016l.484-.371 2.634-7L15.151 6H13zm-1 0V4H6.5l-.354-.146L5.293 3H1v7.417l1.025-3.075L2.5 7h4.793l.853-.854L8.5 6H12zM1.193 13h10.94L14.5 7H8.707l-.853.854L7.5 8H2.86l-1.667 5z" clip-rule="evenodd"/>
</svg>

+ 3
- 0
images/light/icon-open-folder.svg Visa fil

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16">
<path fill="#424242" fill-rule="evenodd" d="M13 6V3.5l-.5-.5H6.707l-.853-.854L5.5 2h-5l-.5.5v11l.5.5-.475-.658.071-.214-.071.214L.5 14h12.016l.484-.371 2.634-7L15.151 6H13zm-1 0V4H6.5l-.354-.146L5.293 3H1v7.417l1.025-3.075L2.5 7h4.793l.853-.854L8.5 6H12zM1.193 13h10.94L14.5 7H8.707l-.853.854L7.5 8H2.86l-1.667 5z" clip-rule="evenodd"/>
</svg>

+ 31
- 4
package.json Visa fil

@ -2439,9 +2439,22 @@
}
},
{
"command": "gitlens.views.exploreRepoRevision",
"command": "gitlens.exploreRepoAtRevision",
"title": "Explore Repository from Here",
"category": "GitLens"
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-open-folder.svg",
"light": "images/light/icon-open-folder.svg"
}
},
{
"command": "gitlens.views.exploreRepoAtRevision",
"title": "Explore Repository from Here",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-open-folder.svg",
"light": "images/light/icon-open-folder.svg"
}
},
{
"command": "gitlens.fetchRepositories",
@ -3497,7 +3510,11 @@
"when": "false"
},
{
"command": "gitlens.views.exploreRepoRevision",
"command": "gitlens.exploreRepoAtRevision",
"when": "gitlens:activeFileStatus =~ /revision/"
},
{
"command": "gitlens.views.exploreRepoAtRevision",
"when": "false"
},
{
@ -4026,6 +4043,11 @@
"group": "navigation@2"
},
{
"command": "gitlens.exploreRepoAtRevision",
"when": "gitlens:activeFileStatus =~ /revision/",
"group": "navigation@3"
},
{
"command": "gitlens.diffWithPrevious",
"alt": "gitlens.diffWithRevision",
"when": "!isInDiffEditor && gitlens:activeFileStatus =~ /tracked/ && config.gitlens.menus.editorGroup.compare",
@ -4111,6 +4133,11 @@
"group": "1_co_gitlens_2@2"
},
{
"command": "gitlens.exploreRepoAtRevision",
"when": "resourceScheme == gitlens",
"group": "1_co_gitlens_3@1"
},
{
"command": "gitlens.copyRemoteFileUrlToClipboard",
"when": "gitlens:enabled && gitlens:hasRemotes && config.gitlens.menus.editorTab.clipboard",
"group": "1_cutcopypaste@100"
@ -4881,7 +4908,7 @@
"group": "8_gitlens_@1"
},
{
"command": "gitlens.views.exploreRepoRevision",
"command": "gitlens.views.exploreRepoAtRevision",
"when": "viewItem =~ /gitlens:(branch|commit|file\\b((?=.*?\\b\\+committed\\b)|:results)|stash|tag)\\b/",
"group": "7_gitlens_more@1"
},

+ 1
- 0
src/commands.ts Visa fil

@ -16,6 +16,7 @@ export * from './commands/diffWithPrevious';
export * from './commands/diffWithRef';
export * from './commands/diffWithRevision';
export * from './commands/diffWithWorking';
export * from './commands/exploreRepoAtRevision';
export * from './commands/externalDiff';
export * from './commands/inviteToLiveShare';
export * from './commands/openBranchesInRemote';

+ 1
- 0
src/commands/common.ts Visa fil

@ -51,6 +51,7 @@ export enum Commands {
DiffWithWorking = 'gitlens.diffWithWorking',
DiffWithWorkingInDiff = 'gitlens.diffWithWorkingInDiff',
DiffLineWithWorking = 'gitlens.diffLineWithWorking',
ExploreRepoAtRevision = 'gitlens.exploreRepoAtRevision',
ExternalDiff = 'gitlens.externalDiff',
FetchRepositories = 'gitlens.fetchRepositories',
InviteToLiveShare = 'gitlens.inviteToLiveShare',

+ 48
- 0
src/commands/exploreRepoAtRevision.ts Visa fil

@ -0,0 +1,48 @@
'use strict';
import * as paths from 'path';
import { commands, TextEditor, Uri } from 'vscode';
import { GitUri } from '../git/gitService';
import { ActiveEditorCommand, command, Commands, getCommandUri, openWorkspace } from './common';
import { toGitLensFSUri } from '../git/fsProvider';
import { BuiltInCommands } from '../constants';
import { Logger } from '../logger';
import { Messages } from '../messages';
export interface ExploreRepoAtRevisionCommandArgs {
uri?: Uri;
}
@command()
export class ExploreRepoAtRevisionCommand extends ActiveEditorCommand {
constructor() {
super(Commands.ExploreRepoAtRevision);
}
async execute(editor: TextEditor, uri?: Uri, args: ExploreRepoAtRevisionCommandArgs = {}) {
args = { ...args };
try {
if (args.uri == null) {
uri = getCommandUri(uri, editor);
if (uri == null) return undefined;
} else {
uri = args.uri;
}
let gitUri = await GitUri.fromUri(uri);
if (gitUri.sha === undefined) return undefined;
uri = toGitLensFSUri(gitUri.sha, gitUri.repoPath!);
gitUri = GitUri.fromRevisionUri(uri);
openWorkspace(uri, `${paths.basename(gitUri.repoPath!)} @ ${gitUri.shortSha}`);
void commands.executeCommand(BuiltInCommands.FocusFilesExplorer);
return undefined;
} catch (ex) {
Logger.error(ex, 'ExploreRepoAtRevisionCommand');
return Messages.showGenericErrorMessage('Unable to open the repository to the specified revision');
}
}
}

+ 5
- 17
src/views/viewCommands.ts Visa fil

@ -1,5 +1,4 @@
'use strict';
import * as paths from 'path';
import { commands, env, TextDocumentShowOptions, Uri, window } from 'vscode';
import {
Commands,
@ -11,12 +10,10 @@ import {
openEditor,
OpenFileInRemoteCommandArgs,
OpenFileRevisionCommandArgs,
OpenWorkingFileCommandArgs,
openWorkspace
OpenWorkingFileCommandArgs
} from '../commands';
import { BuiltInCommands, CommandContext, setCommandContext } from '../constants';
import { Container } from '../container';
import { toGitLensFSUri } from '../git/fsProvider';
import { GitReference, GitService, GitUri } from '../git/gitService';
import {
BranchNode,
@ -107,7 +104,7 @@ export class ViewCommands {
commands.registerCommand('gitlens.views.star', this.star, this);
commands.registerCommand('gitlens.views.unstar', this.unstar, this);
commands.registerCommand('gitlens.views.exploreRepoRevision', this.exploreRepoRevision, this);
commands.registerCommand('gitlens.views.exploreRepoAtRevision', this.exploreRepoAtRevision, this);
commands.registerCommand('gitlens.views.contributor.addCoauthoredBy', this.contributorAddCoAuthoredBy, this);
commands.registerCommand('gitlens.views.contributor.copyToClipboard', this.contributorCopyToClipboard, this);
@ -274,19 +271,10 @@ export class ViewCommands {
}
@debug()
private exploreRepoRevision(node: ViewRefNode, options: { openInNewWindow?: boolean } = {}) {
if (!(node instanceof ViewRefNode)) return;
if (options == null) {
options = {};
}
const uri = toGitLensFSUri(node.ref, node.repoPath);
const gitUri = GitUri.fromRevisionUri(uri);
openWorkspace(uri, `${paths.basename(gitUri.repoPath!)} @ ${gitUri.shortSha}`, options);
private exploreRepoAtRevision(node: ViewRefNode) {
if (!(node instanceof ViewRefNode)) return undefined;
void commands.executeCommand(BuiltInCommands.FocusFilesExplorer);
return commands.executeCommand(Commands.ExploreRepoAtRevision, { uri: node.uri });
}
@debug()

Laddar…
Avbryt
Spara