Merge branch 'bill-mybiz-bill_prev_comm_msg'
This commit is contained in:
commit
fcdc90c7b0
|
@ -29,6 +29,7 @@ import { IGitService, IFileStatus, Status, StatusType, ServiceState, IModel, IBr
|
|||
import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService';
|
||||
import paths = require('vs/base/common/paths');
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
|
||||
function flatten(context?: any, preferFocus = false): IFileStatus[] {
|
||||
if (!context) {
|
||||
|
@ -1117,7 +1118,8 @@ export class UndoLastCommitAction extends GitAction {
|
|||
constructor(
|
||||
id = UndoLastCommitAction.ID,
|
||||
label = UndoLastCommitAction.LABEL,
|
||||
@IGitService gitService: IGitService
|
||||
@IGitService gitService: IGitService,
|
||||
@IStorageService private storageService: IStorageService
|
||||
) {
|
||||
super(UndoLastCommitAction.ID, UndoLastCommitAction.LABEL, 'git-action undo-last-commit', gitService);
|
||||
}
|
||||
|
|
|
@ -695,6 +695,10 @@ export class GitService extends ee.EventEmitter
|
|||
return this.raw.getCommitTemplate();
|
||||
}
|
||||
|
||||
public getCommit(ref: string): winjs.TPromise<git.ICommit> {
|
||||
return this.raw.getCommit(ref);
|
||||
}
|
||||
|
||||
public detectMimetypes(path: string, treeish: string = '~'): winjs.Promise {
|
||||
return this.raw.detectMimetypes(path, treeish);
|
||||
}
|
||||
|
|
|
@ -244,6 +244,14 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
|
|||
}
|
||||
}
|
||||
|
||||
private onUndoLastCommit(commit: git.ICommit): void {
|
||||
if (this.commitInputBox.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.commitInputBox.value = commit.message;
|
||||
}
|
||||
|
||||
private updateCommitInputTemplate(): void {
|
||||
if (this.commitInputBox.value) {
|
||||
return;
|
||||
|
@ -401,6 +409,14 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
|
|||
if (this.commitInputBox) {
|
||||
this.commitInputBox.disable();
|
||||
}
|
||||
} else if (operation.id === git.ServiceOperations.RESET) {
|
||||
const promise = this.gitService.getCommit('HEAD');
|
||||
const listener = this.gitService.addListener2(git.ServiceEvents.OPERATION_END, e => {
|
||||
if (e.operation.id === git.ServiceOperations.RESET && !e.error) {
|
||||
promise.done(c => this.onUndoLastCommit(c));
|
||||
listener.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,11 @@ export interface IRawStatus {
|
|||
remotes: IRemote[];
|
||||
}
|
||||
|
||||
export interface ICommit {
|
||||
hash: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
// Model enums
|
||||
|
||||
export enum StatusType {
|
||||
|
@ -287,6 +292,7 @@ export interface IRawGitService {
|
|||
detectMimetypes(path: string, treeish?: string): TPromise<string[]>;
|
||||
show(path: string, treeish?: string): TPromise<string>;
|
||||
getCommitTemplate(): TPromise<string>;
|
||||
getCommit(ref: string): TPromise<ICommit>;
|
||||
}
|
||||
|
||||
export const GIT_SERVICE_ID = 'gitService';
|
||||
|
@ -324,6 +330,7 @@ export interface IGitService extends IEventEmitter {
|
|||
getRunningOperations(): IGitOperation[];
|
||||
getAutoFetcher(): IAutoFetcher;
|
||||
getCommitTemplate(): TPromise<string>;
|
||||
getCommit(ref: string): TPromise<ICommit>;
|
||||
}
|
||||
|
||||
export interface IAskpassService {
|
||||
|
|
|
@ -9,7 +9,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
|||
import { IChannel, eventToCall, eventFromCall } from 'vs/base/parts/ipc/common/ipc';
|
||||
import Event from 'vs/base/common/event';
|
||||
import { IRawGitService, RawServiceState, IRawStatus, IPushOptions, IAskpassService, ICredentials,
|
||||
ServiceState, IRawFileStatus, IBranch, RefType, IRef, IRemote } from './git';
|
||||
ServiceState, IRawFileStatus, IBranch, RefType, IRef, IRemote, ICommit } from './git';
|
||||
|
||||
type ISerializer<A,B> = { to(a: A): B; from(b: B): A; };
|
||||
|
||||
|
@ -88,6 +88,7 @@ export interface IGitChannel extends IChannel {
|
|||
call(command: 'show', args: [string, string]): TPromise<string>;
|
||||
call(command: 'onOutput'): TPromise<void>;
|
||||
call(command: 'getCommitTemplate'): TPromise<string>;
|
||||
call(command: 'getCommit', ref: string): TPromise<ICommit>;
|
||||
call(command: string, args: any): TPromise<any>;
|
||||
}
|
||||
|
||||
|
@ -119,6 +120,7 @@ export class GitChannel implements IGitChannel {
|
|||
case 'show': return this.service.then(s => s.show(args[0], args[1]));
|
||||
case 'onOutput': return this.service.then(s => eventToCall(s.onOutput));
|
||||
case 'getCommitTemplate': return this.service.then(s => s.getCommitTemplate());
|
||||
case 'getCommit': return this.service.then(s => s.getCommit(args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,6 +225,10 @@ export class GitChannelClient implements IRawGitService {
|
|||
getCommitTemplate(): TPromise<string> {
|
||||
return this.channel.call('getCommitTemplate');
|
||||
}
|
||||
|
||||
getCommit(ref: string): TPromise<ICommit> {
|
||||
return this.channel.call('getCommit', ref);
|
||||
}
|
||||
}
|
||||
|
||||
export interface IAskpassChannel extends IChannel {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { IRawGitService, IRawStatus, ServiceState, RawServiceState } from 'vs/workbench/parts/git/common/git';
|
||||
import { IRawGitService, IRawStatus, ServiceState, RawServiceState, ICommit } from 'vs/workbench/parts/git/common/git';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
|
||||
|
@ -105,4 +105,8 @@ export class NoOpGitService implements IRawGitService {
|
|||
getCommitTemplate(): TPromise<string> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
getCommit(ref: string): TPromise<ICommit> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
}
|
|
@ -261,6 +261,11 @@ export class Git {
|
|||
}
|
||||
}
|
||||
|
||||
export interface ICommit {
|
||||
hash: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export class Repository {
|
||||
|
||||
private git: Git;
|
||||
|
@ -723,6 +728,18 @@ export class Repository {
|
|||
}, () => '');
|
||||
}
|
||||
|
||||
getCommit(ref: string): TPromise<ICommit> {
|
||||
return this.run(['show', '-s', '--format=%H\n%B', ref]).then(result => {
|
||||
const match = /^([0-9a-f]{40})\n([^]*)$/m.exec(result.stdout.trim());
|
||||
|
||||
if (!match) {
|
||||
return TPromise.wrapError('bad commit format');
|
||||
}
|
||||
|
||||
return { hash: match[1], message: match[2] };
|
||||
});
|
||||
}
|
||||
|
||||
onOutput(listener: (output: string) => void): () => void {
|
||||
return this.git.onOutput(listener);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import { TPromise, Promise } from 'vs/base/common/winjs.base';
|
|||
import { detectMimesFromFile, detectMimesFromStream } from 'vs/base/node/mime';
|
||||
import { realpath, exists} from 'vs/base/node/pfs';
|
||||
import { Repository, GitError } from 'vs/workbench/parts/git/node/git.lib';
|
||||
import { IRawGitService, RawServiceState, IRawStatus, IRef, GitErrorCodes, IPushOptions } from 'vs/workbench/parts/git/common/git';
|
||||
import { IRawGitService, RawServiceState, IRawStatus, IRef, GitErrorCodes, IPushOptions, ICommit } from 'vs/workbench/parts/git/common/git';
|
||||
import Event, { Emitter, fromPromise } from 'vs/base/common/event';
|
||||
|
||||
export class RawGitService implements IRawGitService {
|
||||
|
@ -199,6 +199,10 @@ export class RawGitService implements IRawGitService {
|
|||
getCommitTemplate(): TPromise<string> {
|
||||
return this.repo.getCommitTemplate();
|
||||
}
|
||||
|
||||
getCommit(ref: string): TPromise<ICommit> {
|
||||
return this.repo.getCommit(ref);
|
||||
}
|
||||
}
|
||||
|
||||
export class DelayedRawGitService implements IRawGitService {
|
||||
|
@ -225,4 +229,5 @@ export class DelayedRawGitService implements IRawGitService {
|
|||
detectMimetypes(path: string, treeish?: string): TPromise<string[]> { return this.raw.then(r => r.detectMimetypes(path, treeish)); }
|
||||
show(path: string, treeish?: string): TPromise<string> { return this.raw.then(r => r.show(path, treeish)); }
|
||||
getCommitTemplate(): TPromise<string> { return this.raw.then(r => r.getCommitTemplate()); }
|
||||
getCommit(ref: string): TPromise<ICommit> { return this.raw.then(r => r.getCommit(ref)); }
|
||||
}
|
Loading…
Reference in a new issue