提交 4711312d 编写于 作者: J Joao Moreno

show remote url in pick list

fixes #5974
上级 1f9c258c
......@@ -170,6 +170,21 @@ export function distinct<T>(array: T[], keyFn?: (t: T) => string): T[] {
});
}
export function uniqueFilter<T>(keyFn: (t: T) => string): (t: T) => boolean {
const seen: { [key: string]: boolean; } = Object.create(null);
return element => {
const key = keyFn(element);
if (seen[key]) {
return false;
}
seen[key] = true;
return true;
};
}
export function firstIndex<T>(array: T[], fn: (item: T) => boolean): number {
for (let i = 0; i < array.length; i++) {
const element = array[i];
......
......@@ -1029,9 +1029,15 @@ export class PublishAction extends GitAction {
promise = TPromise.as(result ? remoteName : null);
} else {
promise = this.quickOpenService.pick(remotes.map(r => r.name), {
placeHolder: nls.localize('publishPickMessage', "Pick a remote to publish the branch '{0}' to:", branchName)
});
const picks = remotes.map(({ name, url }) => ({
label: name,
description: url
}));
const placeHolder = nls.localize('publishPickMessage', "Pick a remote to publish the branch '{0}' to:", branchName);
promise = this.quickOpenService.pick(picks, { placeHolder })
.then(pick => pick && pick.label);
}
return promise
......
......@@ -23,6 +23,7 @@ export interface IRawFileStatus {
export interface IRemote {
name: string;
url: string;
}
export interface IHead {
......
......@@ -11,6 +11,7 @@ import objects = require('vs/base/common/objects');
import uuid = require('vs/base/common/uuid');
import nls = require('vs/nls');
import strings = require('vs/base/common/strings');
import { uniqueFilter } from 'vs/base/common/arrays';
import { IRawFileStatus, IHead, ITag, IBranch, IRemote, GitErrorCodes, IPushOptions } from 'vs/workbench/parts/git/common/git';
import { detectMimesFromStream } from 'vs/base/node/mime';
import files = require('vs/platform/files/common/files');
......@@ -637,12 +638,17 @@ export class Repository {
}
public getRemotes(): TPromise<IRemote[]> {
return this.run(['remote'], { log: false })
const regex = /^([^\s]+)\s+([^\s]+)\s/;
return this.run(['remote', '--verbose'], { log: false })
.then(result => result.stdout
.trim()
.split('\n')
.filter(b => !!b)
.map(name => ({ name }))
.map(line => regex.exec(line))
.filter(g => !!g)
.map(groups => ({ name: groups[1], url: groups[2] }))
.filter(uniqueFilter<{ name: string; }>(g => g.name))
);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册