mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 12:33:35 +01:00
@@ -7,9 +7,8 @@
|
||||
|
||||
import { Uri, Command, EventEmitter, Event, SourceControlResourceState, SourceControlResourceDecorations, Disposable, ProgressLocation, window, workspace } from 'vscode';
|
||||
import { Git, Repository, Ref, Branch, Remote, PushOptions, Commit, GitErrorCodes } from './git';
|
||||
import { anyEvent, eventToPromise, filterEvent, mapEvent, EmptyDisposable, combinedDisposable, dispose } from './util';
|
||||
import { anyEvent, eventToPromise, filterEvent, EmptyDisposable, combinedDisposable, dispose } from './util';
|
||||
import { memoize, throttle, debounce } from './decorators';
|
||||
import { watch } from './watch';
|
||||
import * as path from 'path';
|
||||
import * as nls from 'vscode-nls';
|
||||
|
||||
@@ -582,11 +581,7 @@ export class Model implements Disposable {
|
||||
const repositoryRoot = await this._git.getRepositoryRoot(this.workspaceRoot.fsPath);
|
||||
this.repository = this._git.open(repositoryRoot);
|
||||
|
||||
const dotGitPath = path.join(repositoryRoot, '.git');
|
||||
const { event: onRawGitChange, disposable: watcher } = watch(dotGitPath);
|
||||
disposables.push(watcher);
|
||||
|
||||
const onGitChange = mapEvent(onRawGitChange, ({ filename }) => Uri.file(path.join(dotGitPath, filename)));
|
||||
const onGitChange = filterEvent(this.onWorkspaceChange, uri => /\/\.git\//.test(uri.fsPath));
|
||||
const onRelevantGitChange = filterEvent(onGitChange, uri => !/\/\.git\/index\.lock$/.test(uri.fsPath));
|
||||
onRelevantGitChange(this.onFSChange, this, disposables);
|
||||
onRelevantGitChange(this._onDidChangeRepository.fire, this._onDidChangeRepository, disposables);
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 { EventEmitter, Event, Disposable } from 'vscode';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export interface FSEvent {
|
||||
eventType: string;
|
||||
filename: string;
|
||||
}
|
||||
|
||||
export function watch(path: string): { event: Event<FSEvent>; disposable: Disposable; } {
|
||||
const emitter = new EventEmitter<FSEvent>();
|
||||
const event = emitter.event;
|
||||
const watcher = fs.watch(path, (eventType, filename) => emitter.fire({ eventType, filename }));
|
||||
const disposable = new Disposable(() => watcher.close());
|
||||
|
||||
return { event, disposable };
|
||||
}
|
||||
Reference in New Issue
Block a user