mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
strictNullChecks for git extension
This commit is contained in:
parent
15ed59b227
commit
65786afc7f
|
@ -96,23 +96,22 @@ function findGitHubGitWin32(): Promise<IGit> {
|
|||
|
||||
function findGitWin32(): Promise<IGit> {
|
||||
return findSystemGitWin32(process.env['ProgramW6432'])
|
||||
.then(null, () => findSystemGitWin32(process.env['ProgramFiles(x86)']))
|
||||
.then(null, () => findSystemGitWin32(process.env['ProgramFiles']))
|
||||
.then(null, () => findSpecificGit('git'))
|
||||
.then(null, () => findGitHubGitWin32());
|
||||
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles(x86)']))
|
||||
.then(void 0, () => findSystemGitWin32(process.env['ProgramFiles']))
|
||||
.then(void 0, () => findSpecificGit('git'))
|
||||
.then(void 0, () => findGitHubGitWin32());
|
||||
}
|
||||
|
||||
export function findGit(hint: string): Promise<IGit> {
|
||||
export function findGit(hint: string | undefined): Promise<IGit> {
|
||||
var first = hint ? findSpecificGit(hint) : Promise.reject<IGit>(null);
|
||||
|
||||
return first.then(null, () => {
|
||||
return first.then(void 0, () => {
|
||||
switch (process.platform) {
|
||||
case 'darwin': return findGitDarwin();
|
||||
case 'win32': return findGitWin32();
|
||||
default: return findSpecificGit('git');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,28 +177,28 @@ export interface IGitErrorData {
|
|||
|
||||
export class GitError {
|
||||
|
||||
error: Error;
|
||||
error?: Error;
|
||||
message: string;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
gitErrorCode: string;
|
||||
gitCommand: string;
|
||||
stdout?: string;
|
||||
stderr?: string;
|
||||
exitCode?: number;
|
||||
gitErrorCode?: string;
|
||||
gitCommand?: string;
|
||||
|
||||
constructor(data: IGitErrorData) {
|
||||
if (data.error) {
|
||||
this.error = data.error;
|
||||
this.message = data.error.message;
|
||||
} else {
|
||||
this.error = null;
|
||||
this.error = void 0;
|
||||
}
|
||||
|
||||
this.message = this.message || data.message || 'Git error';
|
||||
this.stdout = data.stdout || null;
|
||||
this.stderr = data.stderr || null;
|
||||
this.exitCode = data.exitCode || null;
|
||||
this.gitErrorCode = data.gitErrorCode || null;
|
||||
this.gitCommand = data.gitCommand || null;
|
||||
this.stdout = data.stdout;
|
||||
this.stderr = data.stderr;
|
||||
this.exitCode = data.exitCode;
|
||||
this.gitErrorCode = data.gitErrorCode;
|
||||
this.gitCommand = data.gitCommand;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
|
@ -209,7 +208,7 @@ export class GitError {
|
|||
gitCommand: this.gitCommand,
|
||||
stdout: this.stdout,
|
||||
stderr: this.stderr
|
||||
}, null, 2);
|
||||
}, [], 2);
|
||||
|
||||
if (this.error) {
|
||||
result += (<any>this.error).stack;
|
||||
|
@ -289,7 +288,7 @@ export class Git {
|
|||
|
||||
return exec(child).then(result => {
|
||||
if (result.exitCode) {
|
||||
let gitErrorCode: string = null;
|
||||
let gitErrorCode: string | undefined = void 0;
|
||||
|
||||
if (/Authentication failed/.test(result.stderr)) {
|
||||
gitErrorCode = GitErrorCodes.AuthenticationFailed;
|
||||
|
|
|
@ -15,11 +15,11 @@ export function log(...args: any[]): void {
|
|||
|
||||
class GitSCMProvider {
|
||||
resourceGroups = [];
|
||||
onDidChangeResourceGroup = null;
|
||||
onDidChangeResourceGroup: any = null;
|
||||
|
||||
getOriginalResource(uri: Uri): Uri {
|
||||
getOriginalResource(uri: Uri): Uri | undefined {
|
||||
if (uri.scheme !== 'file') {
|
||||
return null;
|
||||
return void 0;
|
||||
}
|
||||
|
||||
return uri.with({ scheme: 'git-index' });
|
||||
|
@ -27,10 +27,11 @@ class GitSCMProvider {
|
|||
}
|
||||
|
||||
export function activate(context: ExtensionContext): any {
|
||||
if (!workspace) {
|
||||
if (!workspace.rootPath) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rootPath = workspace.rootPath;
|
||||
const pathHint = workspace.getConfiguration('git').get<string>('path');
|
||||
|
||||
findGit(pathHint).then(info => {
|
||||
|
@ -42,9 +43,9 @@ export function activate(context: ExtensionContext): any {
|
|||
|
||||
const contentProvider = workspace.registerTextDocumentContentProvider('git-index', {
|
||||
provideTextDocumentContent: uri => {
|
||||
const relativePath = path.relative(workspace.rootPath, uri.fsPath);
|
||||
const relativePath = path.relative(rootPath, uri.fsPath);
|
||||
|
||||
return git.exec(workspace.rootPath, ['show', `HEAD:${relativePath}`]).then(result => {
|
||||
return git.exec(rootPath, ['show', `HEAD:${relativePath}`]).then(result => {
|
||||
if (result.exitCode !== 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -35,32 +35,3 @@ export function filterEvent<T>(event: Event<T>, filter: (e: T) => boolean): Even
|
|||
export function anyEvent<T>(...events: Event<T>[]): Event<T> {
|
||||
return (listener, thisArgs = null, disposables?) => combinedDisposable(events.map(event => event(i => listener.call(thisArgs, i), disposables)));
|
||||
}
|
||||
|
||||
interface IListener<T> {
|
||||
(e: T): any;
|
||||
}
|
||||
|
||||
export class Emitter<T> {
|
||||
|
||||
private listeners: IListener<T>[];
|
||||
|
||||
get event(): Event<T> {
|
||||
return (listener: IListener<T>, thisArgs = null, disposables?: IDisposable[]) => {
|
||||
const _listener = thisArgs ? listener.bind(thisArgs) : listener;
|
||||
this.listeners.push(_listener);
|
||||
|
||||
const dispose = () => { this.listeners = this.listeners.filter(l => l !== _listener); };
|
||||
const result = { dispose };
|
||||
|
||||
if (disposables) {
|
||||
disposables.push(result);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
fire(e: T = null): void {
|
||||
|
||||
}
|
||||
}
|
|
@ -3,7 +3,8 @@
|
|||
"noLib": true,
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"outDir": "./out"
|
||||
"outDir": "./out",
|
||||
"strictNullChecks": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
|
|
2
src/vs/vscode.proposed.d.ts
vendored
2
src/vs/vscode.proposed.d.ts
vendored
|
@ -100,7 +100,7 @@ declare module 'vscode' {
|
|||
dragCommand?: string;
|
||||
resourceGroups: SCMResourceGroup[];
|
||||
onDidChangeResourceGroup: Event<SCMResourceGroup>;
|
||||
getOriginalResource?(uri: Uri, token: CancellationToken): Uri | Thenable<Uri>;
|
||||
getOriginalResource?(uri: Uri, token: CancellationToken): ProviderResult<Uri>;
|
||||
}
|
||||
|
||||
export namespace scm {
|
||||
|
|
Loading…
Reference in a new issue