Merge branch 'bill-mybiz-bill_test_git'
This commit is contained in:
commit
c76e6a2e2a
|
@ -691,6 +691,10 @@ export class GitService extends ee.EventEmitter
|
|||
return this.run(git.ServiceOperations.COMMIT, () => this.raw.commit(message, amend, stage));
|
||||
}
|
||||
|
||||
public getCommitTemplate(): winjs.Promise {
|
||||
return this.raw.getCommitTemplate();
|
||||
}
|
||||
|
||||
public detectMimetypes(path: string, treeish: string = '~'): winjs.Promise {
|
||||
return this.raw.detectMimetypes(path, treeish);
|
||||
}
|
||||
|
|
|
@ -236,14 +236,24 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
|
|||
|
||||
if (visible) {
|
||||
this.tree.onVisible();
|
||||
this.updateCommitInputTemplate();
|
||||
return this.onEditorsChanged(this.editorService.getActiveEditorInput());
|
||||
|
||||
} else {
|
||||
this.tree.onHidden();
|
||||
return WinJS.TPromise.as(null);
|
||||
}
|
||||
}
|
||||
|
||||
private updateCommitInputTemplate(): void {
|
||||
if (this.commitInputBox.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.gitService.getCommitTemplate()
|
||||
.then(template => template && (this.commitInputBox.value = template))
|
||||
.done(null, Errors.onUnexpectedError);
|
||||
}
|
||||
|
||||
public getControl(): Tree.ITree {
|
||||
return this.tree;
|
||||
}
|
||||
|
@ -395,12 +405,13 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
|
|||
}
|
||||
|
||||
private onGitOperationEnd(e: { operation: git.IGitOperation; error: any; }): void {
|
||||
if (e.operation.id === git.ServiceOperations.COMMIT) {
|
||||
if (e.operation.id === git.ServiceOperations.COMMIT || e.operation.id === git.ServiceOperations.RESET) {
|
||||
if (this.commitInputBox) {
|
||||
this.commitInputBox.enable();
|
||||
|
||||
if (!e.error) {
|
||||
this.commitInputBox.value = '';
|
||||
this.updateCommitInputTemplate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,6 +286,7 @@ export interface IRawGitService {
|
|||
commit(message:string, amend?: boolean, stage?: boolean): TPromise<IRawStatus>;
|
||||
detectMimetypes(path: string, treeish?: string): TPromise<string[]>;
|
||||
show(path: string, treeish?: string): TPromise<string>;
|
||||
getCommitTemplate(): TPromise<string>;
|
||||
}
|
||||
|
||||
export var GIT_SERVICE_ID = 'gitService';
|
||||
|
@ -322,6 +323,7 @@ export interface IGitService extends IEventEmitter {
|
|||
isIdle(): boolean;
|
||||
getRunningOperations(): IGitOperation[];
|
||||
getAutoFetcher(): IAutoFetcher;
|
||||
getCommitTemplate(): TPromise<string>;
|
||||
}
|
||||
|
||||
export interface IAskpassService {
|
||||
|
|
|
@ -87,6 +87,7 @@ export interface IGitChannel extends IChannel {
|
|||
call(command: 'detectMimetypes', args: [string, string]): TPromise<string[]>;
|
||||
call(command: 'show', args: [string, string]): TPromise<string>;
|
||||
call(command: 'onOutput'): TPromise<void>;
|
||||
call(command: 'getCommitTemplate'): TPromise<string>;
|
||||
call(command: string, args: any): TPromise<any>;
|
||||
}
|
||||
|
||||
|
@ -117,6 +118,7 @@ export class GitChannel implements IGitChannel {
|
|||
case 'detectMimetypes': return this.service.then(s => s.detectMimetypes(args[0], args[1]));
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +219,10 @@ export class GitChannelClient implements IRawGitService {
|
|||
show(path: string, treeish?: string): TPromise<string> {
|
||||
return this.channel.call('show', [path, treeish]);
|
||||
}
|
||||
|
||||
getCommitTemplate(): TPromise<string> {
|
||||
return this.channel.call('getCommitTemplate');
|
||||
}
|
||||
}
|
||||
|
||||
export interface IAskpassChannel extends IChannel {
|
||||
|
|
|
@ -101,4 +101,8 @@ export class NoOpGitService implements IRawGitService {
|
|||
show(path: string, treeish?: string): TPromise<string> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
getCommitTemplate(): TPromise<string> {
|
||||
return TPromise.as(null);
|
||||
}
|
||||
}
|
|
@ -3,8 +3,11 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { Promise, TPromise } from 'vs/base/common/winjs.base';
|
||||
import { del } from 'vs/base/node/extfs';
|
||||
import * as pfs from 'vs/base/node/pfs';
|
||||
import { guessMimeTypes, isBinaryMime } from 'vs/base/common/mime';
|
||||
import { IDisposable, toDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
@ -697,6 +700,21 @@ export class Repository {
|
|||
});
|
||||
}
|
||||
|
||||
getCommitTemplate(): TPromise<string> {
|
||||
return this.run(['config', '--get', 'commit.template']).then(result => {
|
||||
if (!result.stdout) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// https://github.com/git/git/blob/3a0f269e7c82aa3a87323cb7ae04ac5f129f036b/path.c#L612
|
||||
const homedir = os.homedir();
|
||||
const templatePath = result.stdout.trim()
|
||||
.replace(/^~([^\/]*)\//, (_, user) => `${ user ? path.join(path.dirname(homedir), user) : homedir }/`);
|
||||
|
||||
return pfs.readFile(templatePath, 'utf8').then(null, () => '');
|
||||
}, () => '');
|
||||
}
|
||||
|
||||
onOutput(listener: (output: string) => void): () => void {
|
||||
return this.git.onOutput(listener);
|
||||
}
|
||||
|
|
|
@ -195,6 +195,10 @@ export class RawGitService implements IRawGitService {
|
|||
return TPromise.wrapError<string>(e);
|
||||
});
|
||||
}
|
||||
|
||||
getCommitTemplate(): TPromise<string> {
|
||||
return this.repo.getCommitTemplate();
|
||||
}
|
||||
}
|
||||
|
||||
export class DelayedRawGitService implements IRawGitService {
|
||||
|
@ -220,4 +224,5 @@ export class DelayedRawGitService implements IRawGitService {
|
|||
commit(message:string, amend?: boolean, stage?: boolean): TPromise<IRawStatus> { return this.raw.then(r => r.commit(message, amend, stage)); }
|
||||
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()); }
|
||||
}
|
Loading…
Reference in a new issue