提交 01e466ee 编写于 作者: J Joao Moreno

git: publish command, statusbar

上级 4c3f63a3
......@@ -93,6 +93,11 @@
"light": "resources/icons/light/clean.svg",
"dark": "resources/icons/dark/clean.svg"
}
},
{
"command": "git.publish",
"title": "Publish",
"category": "Git"
}
],
"menus": {
......
......@@ -90,7 +90,8 @@ class CommandCenter {
commands.registerCommand('git.unstageAll', this.unstageAll, this),
commands.registerCommand('git.clean', this.clean, this),
commands.registerCommand('git.cleanAll', this.cleanAll, this),
commands.registerCommand('git.checkout', this.checkout, this)
commands.registerCommand('git.checkout', this.checkout, this),
commands.registerCommand('git.publish', this.publish, this),
);
}
......@@ -192,9 +193,9 @@ class CommandCenter {
const remoteHeads = (includeRemotes ? this.model.refs.filter(ref => ref.type === RefType.RemoteHead) : [])
.map(ref => new CheckoutRemoteHeadItem(ref));
const choice = await window.showQuickPick<CheckoutItem>([...heads, ...tags, ...remoteHeads], {
placeHolder: 'Select a ref to checkout'
});
const picks = [...heads, ...tags, ...remoteHeads];
const placeHolder = 'Select a ref to checkout';
const choice = await window.showQuickPick<CheckoutItem>(picks, { placeHolder });
if (!choice) {
return;
......@@ -203,6 +204,20 @@ class CommandCenter {
await choice.run(this.model);
}
@decorate(catchErrors)
async publish(): Promise<void> {
const branchName = this.model.HEAD && this.model.HEAD.name || '';
const picks = this.model.remotes.map(r => r.name);
const placeHolder = `Pick a remote to publish the branch '${branchName}' to:`;
const choice = await window.showQuickPick(picks, { placeHolder });
if (!choice) {
return;
}
await this.model.push(choice, branchName, { setUpstream: true });
}
dispose(): void {
this.disposables.forEach(d => d.dispose());
}
......
......@@ -6,7 +6,7 @@
'use strict';
import { Uri, EventEmitter, Event, SCMResource, SCMResourceDecorations, SCMResourceGroup } from 'vscode';
import { Repository, IRef, IBranch, IRemote } from './git';
import { Repository, IRef, IBranch, IRemote, IPushOptions } from './git';
import { throttle } from './util';
import { decorate } from 'core-decorators';
import * as path from 'path';
......@@ -193,12 +193,12 @@ export class Model {
return this._HEAD;
}
private _refs: IRef[];
private _refs: IRef[] = [];
get refs(): IRef[] {
return this._refs;
}
private _remotes: IRemote[];
private _remotes: IRemote[] = [];
get remotes(): IRemote[] {
return this._remotes;
}
......@@ -326,4 +326,9 @@ export class Model {
await this.repository.checkout(treeish, []);
await this.update();
}
async push(remote?: string, name?: string, options?: IPushOptions): Promise<void> {
await this.repository.push(remote, name, options);
await this.update();
}
}
\ No newline at end of file
......@@ -58,8 +58,6 @@ export class SyncStatusBar {
constructor(private model: Model) {
this.raw = window.createStatusBarItem(StatusBarAlignment.Left);
this.disposables.push(this.raw);
model.onDidChange(this.update, this, this.disposables);
this.update();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册