fix bad watch

This commit is contained in:
Joao Moreno
2019-06-25 11:40:46 +02:00
parent 57b7f06fac
commit c7b6044d0f

View File

@@ -488,7 +488,10 @@ class DotGitWatcher implements IFileWatcher {
private transientDisposables: IDisposable[] = [];
private disposables: IDisposable[] = [];
constructor(private repository: Repository) {
constructor(
private repository: Repository,
private outputChannel: OutputChannel
) {
const rootWatcher = watch(repository.dotGit);
this.disposables.push(rootWatcher);
@@ -511,9 +514,15 @@ class DotGitWatcher implements IFileWatcher {
const { name, remote } = this.repository.HEAD.upstream;
const upstreamPath = path.join(this.repository.dotGit, 'refs', 'remotes', remote, name);
const upstreamWatcher = watch(upstreamPath);
this.transientDisposables.push(upstreamWatcher);
upstreamWatcher.event(this.emitter.fire, this.emitter, this.transientDisposables);
try {
const upstreamWatcher = watch(upstreamPath);
this.transientDisposables.push(upstreamWatcher);
upstreamWatcher.event(this.emitter.fire, this.emitter, this.transientDisposables);
} catch (err) {
if (env.logLevel <= LogLevel.Info) {
this.outputChannel.appendLine(`Failed to watch ref '${upstreamPath}'. Ref is most likely packed.`);
}
}
}
dispose() {
@@ -642,7 +651,7 @@ export class Repository implements Disposable {
const onWorkspaceRepositoryFileChange = filterEvent(onWorkspaceFileChange, uri => isDescendant(repository.root, uri.fsPath));
const onWorkspaceWorkingTreeFileChange = filterEvent(onWorkspaceRepositoryFileChange, uri => !/\/\.git($|\/)/.test(uri.path));
const dotGitFileWatcher = new DotGitWatcher(this);
const dotGitFileWatcher = new DotGitWatcher(this, outputChannel);
this.disposables.push(dotGitFileWatcher);
// FS changes should trigger `git status`: