Skip to content

Commit

Permalink
Fixes add remote & adds to remotes view
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Dec 23, 2020
1 parent 88ac213 commit 579cd47
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6358,6 +6358,11 @@
"when": "view =~ /^gitlens\\.views\\.lineHistory/ && config.gitlens.views.lineHistory.avatars",
"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",
Expand Down
13 changes: 12 additions & 1 deletion src/commands/gitCommands.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions src/views/nodes/remotesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class RemotesNode extends ViewNode<RemotesView | RepositoriesView> {
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 });
Expand Down
7 changes: 3 additions & 4 deletions src/views/viewCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
PagerNode,
PullRequestNode,
RemoteNode,
RemotesNode,
RepositoryFolderNode,
RepositoryNode,
ResultsFileNode,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 579cd47

Please sign in to comment.