Browse Source

Fixes add remote & adds to remotes view

main
Eric Amodio 4 years ago
parent
commit
579cd475c6
4 changed files with 24 additions and 5 deletions
  1. +5
    -0
      package.json
  2. +12
    -1
      src/commands/gitCommands.actions.ts
  3. +4
    -0
      src/views/nodes/remotesNode.ts
  4. +3
    -4
      src/views/viewCommands.ts

+ 5
- 0
package.json View File

@ -6359,6 +6359,11 @@
"group": "5_gitlens@0"
},
{
"command": "gitlens.views.addRemote",
"when": "!gitlens:readonly && view =~ /gitlens\\.views\\.remotes/",
"group": "navigation@1"
},
{
"command": "gitlens.views.remotes.setLayoutToList",
"when": "view =~ /gitlens\\.views\\.remotes/ && config.gitlens.views.remotes.branches.layout == tree",
"group": "navigation@50"

+ 12
- 1
src/commands/gitCommands.actions.ts View File

@ -27,6 +27,7 @@ import {
Repository,
} from '../git/git';
import { GitUri } from '../git/gitUri';
import { RepositoryPicker } from '../quickpicks';
import { ResetGitCommandArgs } from './git/reset';
export async function executeGitCommand(args: GitCommandsCommandArgs): Promise<void> {
@ -758,7 +759,17 @@ export namespace GitActions {
}
export namespace Remote {
export async function add(repo: string | Repository) {
export async function add(repo?: string | Repository) {
if (repo == null) {
repo = Container.git.getHighlanderRepoPath();
if (repo == null) {
const pick = await RepositoryPicker.show(undefined, 'Choose a repository to add a remote to');
repo = pick?.item;
if (repo == null) return undefined;
}
}
const name = await window.showInputBox({
prompt: 'Please provide a name for the remote',
placeHolder: 'Remote name',

+ 4
- 0
src/views/nodes/remotesNode.ts View File

@ -26,6 +26,10 @@ export class RemotesNode extends ViewNode {
return RemotesNode.getId(this.repo.path);
}
get repoPath(): string {
return this.repo.path;
}
async getChildren(): Promise<ViewNode[]> {
if (this._children == null) {
const remotes = await this.repo.getRemotes({ sort: true });

+ 3
- 4
src/views/viewCommands.ts View File

@ -33,6 +33,7 @@ import {
PagerNode,
PullRequestNode,
RemoteNode,
RemotesNode,
RepositoryFolderNode,
RepositoryNode,
ResultsFileNode,
@ -220,10 +221,8 @@ export class ViewCommands {
}
@debug()
private addRemote(node: RemoteNode) {
if (!(node instanceof RemoteNode)) return Promise.resolve();
return GitActions.Remote.add(node.repo);
private addRemote(node?: RemotesNode) {
return GitActions.Remote.add(node?.repoPath);
}
@debug()

Loading…
Cancel
Save