mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-13 17:23:11 -05:00
Adds Open Branches in Remote command to the Remote custom view items
Adds Open Repository in Remote command to the Remote custom view items
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@@ -28,11 +28,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
||||
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
|
||||
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
|
||||
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, `Show Commit Details`, and `Refresh` commands
|
||||
- Provides a context menu on each branch with `Open Branch in Remote`, and `Refresh` commands
|
||||
- Provides a context menu with `Open Branches in Remote`, and `Refresh` commands
|
||||
- Provides a context menu on each branch with `Open Branch in Remote`, and `Refresh` commands
|
||||
|
||||
- `Remotes` node — provides a list of the remote branches
|
||||
- See `Branches` node above for details
|
||||
- `Remotes` node — provides a list of remotes
|
||||
- Expand each remote to see its list of branches
|
||||
- Expand each branch to easily see its revision (commit) history
|
||||
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
|
||||
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
|
||||
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, `Show Commit Details`, and `Refresh` commands
|
||||
- Provides a context menu on each remote with `Open Branches in Remote`, `Open Repository in Remote`, and `Refresh` commands
|
||||
- Provides a context menu with a `Refresh` command
|
||||
|
||||
- `Stashes` node — provides a list of stashed changes
|
||||
- Expand each stash to quickly see the set of files stashed, complete with status indicators for adds, changes, renames, and deletes
|
||||
|
||||
12
README.md
12
README.md
@@ -133,11 +133,17 @@ GitLens provides an unobtrusive blame annotation at the end of the current line,
|
||||
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
|
||||
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
|
||||
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, `Show Commit Details`, and `Refresh` commands
|
||||
- Provides a context menu on each branch with `Open Branch in Remote`, and `Refresh` commands
|
||||
- Provides a context menu with `Open Branches in Remote`, and `Refresh` commands
|
||||
- Provides a context menu on each branch with `Open Branch in Remote`, and `Refresh` commands
|
||||
|
||||
- `Remotes` node — provides a list of the remote branches
|
||||
- See `Branches` node above for details
|
||||
- `Remotes` node — provides a list of remotes
|
||||
- Expand each remote to see its list of branches
|
||||
- Expand each branch to easily see its revision (commit) history
|
||||
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
|
||||
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
|
||||
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Open Files`, `Open Revisions`, `Show Commit Details`, and `Refresh` commands
|
||||
- Provides a context menu on each remote with `Open Branches in Remote`, `Open Repository in Remote`, and `Refresh` commands
|
||||
- Provides a context menu with a `Refresh` command
|
||||
|
||||
- `Stashes` node — provides a list of stashed changes
|
||||
- Expand each stash to quickly see the set of files stashed, complete with status indicators for adds, changes, renames, and deletes
|
||||
|
||||
10
package.json
10
package.json
@@ -1576,6 +1576,16 @@
|
||||
"when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:file-history",
|
||||
"group": "1_gitlens@2"
|
||||
},
|
||||
{
|
||||
"command": "gitlens.openBranchesInRemote",
|
||||
"when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:remote",
|
||||
"group": "1_gitlens@1"
|
||||
},
|
||||
{
|
||||
"command": "gitlens.openRepoInRemote",
|
||||
"when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:remote",
|
||||
"group": "1_gitlens@2"
|
||||
},
|
||||
{
|
||||
"command": "gitlens.stashSave",
|
||||
"when": "gitlens:enabled && view == gitlens.gitExplorer && viewItem == gitlens:stashes",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
import { commands, Disposable, SourceControlResourceGroup, SourceControlResourceState, TextDocumentShowOptions, TextEditor, TextEditorEdit, Uri, window, workspace } from 'vscode';
|
||||
import { ExplorerNode } from '../views/explorerNodes';
|
||||
import { GitBranch, GitCommit } from '../gitService';
|
||||
import { GitBranch, GitCommit, GitRemote } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import { Telemetry } from '../telemetry';
|
||||
|
||||
@@ -140,6 +140,10 @@ export function isCommandViewContextWithCommit<T extends GitCommit>(context: Com
|
||||
return context.type === 'view' && (context.node as any).commit && (context.node as any).commit instanceof GitCommit;
|
||||
}
|
||||
|
||||
export function isCommandViewContextWithRemote(context: CommandContext): context is CommandViewContext & { node: (ExplorerNode & { remote: GitRemote }) } {
|
||||
return context.type === 'view' && (context.node as any).remote && (context.node as any).remote instanceof GitRemote;
|
||||
}
|
||||
|
||||
export type CommandContext = CommandScmGroupsContext | CommandScmStatesContext | CommandUnknownContext | CommandUriContext | CommandViewContext;
|
||||
|
||||
function isScmResourceGroup(group: any): group is SourceControlResourceGroup {
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
'use strict';
|
||||
import { Arrays } from '../system';
|
||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithRemote } from './common';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import { OpenInRemoteCommandArgs } from './openInRemote';
|
||||
|
||||
export interface OpenBranchesInRemoteCommandArgs {
|
||||
remote?: string;
|
||||
}
|
||||
|
||||
export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.OpenBranchesInRemote);
|
||||
}
|
||||
|
||||
async execute(editor?: TextEditor, uri?: Uri) {
|
||||
protected async preExecute(context: CommandContext, args: OpenBranchesInRemoteCommandArgs = {}): Promise<any> {
|
||||
if (isCommandViewContextWithRemote(context)) {
|
||||
args = { ...args };
|
||||
args.remote = context.node.remote.name;
|
||||
return this.execute(context.editor, context.uri, args);
|
||||
}
|
||||
|
||||
return this.execute(context.editor, context.uri, args);
|
||||
}
|
||||
|
||||
async execute(editor?: TextEditor, uri?: Uri, args: OpenBranchesInRemoteCommandArgs = {}) {
|
||||
uri = getCommandUri(uri, editor);
|
||||
|
||||
const gitUri = uri && await GitUri.fromUri(uri, this.git);
|
||||
@@ -21,7 +35,11 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
|
||||
if (!repoPath) return undefined;
|
||||
|
||||
try {
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(repoPath), _ => _.url, _ => !!_.provider);
|
||||
let remotes = Arrays.uniqueBy(await this.git.getRemotes(repoPath), r => r.url, r => !!r.provider);
|
||||
if (args.remote !== undefined) {
|
||||
remotes = remotes.filter(r => r.name === args.remote);
|
||||
}
|
||||
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, {
|
||||
resource: {
|
||||
type: 'branches'
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
'use strict';
|
||||
import { Arrays } from '../system';
|
||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithRemote } from './common';
|
||||
import { GitService, GitUri } from '../gitService';
|
||||
import { Logger } from '../logger';
|
||||
import { OpenInRemoteCommandArgs } from './openInRemote';
|
||||
|
||||
export interface OpenRepoInRemoteCommandArgs {
|
||||
remote?: string;
|
||||
}
|
||||
|
||||
export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitService) {
|
||||
super(Commands.OpenRepoInRemote);
|
||||
}
|
||||
|
||||
async execute(editor?: TextEditor, uri?: Uri) {
|
||||
protected async preExecute(context: CommandContext, args: OpenRepoInRemoteCommandArgs = {}): Promise<any> {
|
||||
if (isCommandViewContextWithRemote(context)) {
|
||||
args = { ...args };
|
||||
args.remote = context.node.remote.name;
|
||||
return this.execute(context.editor, context.uri, args);
|
||||
}
|
||||
|
||||
return this.execute(context.editor, context.uri, args);
|
||||
}
|
||||
|
||||
async execute(editor?: TextEditor, uri?: Uri, args: OpenRepoInRemoteCommandArgs = {}) {
|
||||
uri = getCommandUri(uri, editor);
|
||||
|
||||
const gitUri = uri && await GitUri.fromUri(uri, this.git);
|
||||
@@ -21,7 +35,11 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
|
||||
if (!repoPath) return undefined;
|
||||
|
||||
try {
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(repoPath), _ => _.url, _ => !!_.provider);
|
||||
let remotes = Arrays.uniqueBy(await this.git.getRemotes(repoPath), r => r.url, r => !!r.provider);
|
||||
if (args.remote !== undefined) {
|
||||
remotes = remotes.filter(r => r.name === args.remote);
|
||||
}
|
||||
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, {
|
||||
resource: {
|
||||
type: 'repo'
|
||||
|
||||
Reference in New Issue
Block a user