mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-14 12:11:43 +01:00
wip: adopt ipc channels in git world
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { RawServiceState, IRawStatus, IPushOptions } from './git';
|
||||
|
||||
export interface IGitChannel extends IChannel {
|
||||
call(command: 'getVersion'): TPromise<string>;
|
||||
call(command: 'serviceState'): TPromise<RawServiceState>;
|
||||
call(command: 'status'): TPromise<IRawStatus>;
|
||||
call(command: 'init'): TPromise<IRawStatus>;
|
||||
call(command: 'add', filesPaths?: string[]): TPromise<IRawStatus>;
|
||||
call(command: 'stage', filePath: string, content: string): TPromise<IRawStatus>;
|
||||
call(command: 'branch', name: string, checkout?: boolean): TPromise<IRawStatus>;
|
||||
call(command: 'checkout', treeish?: string, filePaths?: string[]): TPromise<IRawStatus>;
|
||||
call(command: 'clean', filePaths: string[]): TPromise<IRawStatus>;
|
||||
call(command: 'undo'): TPromise<IRawStatus>;
|
||||
call(command: 'reset', treeish:string, hard?: boolean): TPromise<IRawStatus>;
|
||||
call(command: 'revertFiles', treeish:string, filePaths?: string[]): TPromise<IRawStatus>;
|
||||
call(command: 'fetch'): TPromise<IRawStatus>;
|
||||
call(command: 'pull', rebase?: boolean): TPromise<IRawStatus>;
|
||||
call(command: 'push', remote?: string, name?: string, options?: IPushOptions): TPromise<IRawStatus>;
|
||||
call(command: 'sync'): TPromise<IRawStatus>;
|
||||
call(command: 'commit', message:string, amend?: boolean, stage?: boolean): TPromise<IRawStatus>;
|
||||
call(command: 'detectMimetypes', path: string, treeish?: string): TPromise<string[]>;
|
||||
call(command: 'show', path: string, treeish?: string): TPromise<string>;
|
||||
call(command: 'onOutput'): TPromise<void>;
|
||||
call(command: string, ...args: any[]): TPromise<any>;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ function createNativeRawGitService(workspaceRoot: string, path: string, defaultE
|
||||
}
|
||||
);
|
||||
|
||||
return client.getChannel('GitService', RawGitService);
|
||||
return client.getChannel('git');
|
||||
}, () => new UnavailableRawGitService());
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import mime = require('vs/base/node/mime');
|
||||
import pfs = require('vs/base/node/pfs');
|
||||
import { Repository, GitError } from 'vs/workbench/parts/git/node/git.lib';
|
||||
import { IRawGitService, RawServiceState, IRawStatus, IHead, GitErrorCodes, IPushOptions } from 'vs/workbench/parts/git/common/git';
|
||||
import { IGitChannel } from 'vs/workbench/parts/git/common/gitIpc';
|
||||
|
||||
export class RawGitService implements IRawGitService {
|
||||
|
||||
@@ -262,4 +263,35 @@ export class DelayedRawGitService implements IRawGitService {
|
||||
public onOutput(): Promise {
|
||||
return this.raw.then(raw => raw.onOutput());
|
||||
}
|
||||
}
|
||||
|
||||
export class GitChannel implements IGitChannel {
|
||||
|
||||
constructor(private rawGitService: IRawGitService) { }
|
||||
|
||||
call(command: string, ...args: any[]): TPromise<any> {
|
||||
switch (command) {
|
||||
case 'getVersion': return this.rawGitService.getVersion();
|
||||
case 'serviceState': return this.rawGitService.serviceState();
|
||||
case 'status': return this.rawGitService.status();
|
||||
case 'status': return this.rawGitService.status();
|
||||
case 'init': return this.rawGitService.init();
|
||||
case 'add': return this.rawGitService.add(args[0]);
|
||||
case 'stage': return this.rawGitService.stage(args[0], args[1]);
|
||||
case 'branch': return this.rawGitService.branch(args[0], args[1]);
|
||||
case 'checkout': return this.rawGitService.checkout(args[0], args[1]);
|
||||
case 'clean': return this.rawGitService.clean(args[0]);
|
||||
case 'undo': return this.rawGitService.undo();
|
||||
case 'reset': return this.rawGitService.reset(args[0], args[1]);
|
||||
case 'revertFiles': return this.rawGitService.revertFiles(args[0], args[1]);
|
||||
case 'fetch': return this.rawGitService.fetch();
|
||||
case 'pull': return this.rawGitService.pull(args[0]);
|
||||
case 'push': return this.rawGitService.push(args[0], args[1], args[2]);
|
||||
case 'sync': return this.rawGitService.sync();
|
||||
case 'commit': return this.rawGitService.commit(args[0], args[1], args[2]);
|
||||
case 'detectMimetypes': return this.rawGitService.detectMimetypes(args[0], args[1]);
|
||||
case 'show': return this.rawGitService.show(args[0], args[1]);
|
||||
case 'onOutput': return this.rawGitService.onOutput();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user