Kaynağa Gözat

Fixes stash and remote updates

Adds repo watcher for config changes too
main
Eric Amodio 7 yıl önce
ebeveyn
işleme
15420c554d
1 değiştirilmiş dosya ile 24 ekleme ve 8 silme
  1. +24
    -8
      src/git/models/repository.ts

+ 24
- 8
src/git/models/repository.ts Dosyayı Görüntüle

@ -7,8 +7,9 @@ import { GitService, GitUri } from '../../gitService';
import { RemoteProviderFactory, RemoteProviderMap } from '../remotes/factory';
export enum RepositoryChange {
Config = 'config',
// FileSystem = 'file-system',
RemotesCache = 'remotes-cache',
Remotes = 'remotes',
Repository = 'repository',
Stashes = 'stashes'
}
@ -88,7 +89,7 @@ export class Repository extends Disposable {
this._suspended = suspended;
const watcher = workspace.createFileSystemWatcher(new RelativePattern(folder, '**/.git/{index,HEAD,refs/stash,refs/heads/**,refs/remotes/**}'));
const watcher = workspace.createFileSystemWatcher(new RelativePattern(folder, '**/.git/{config,index,HEAD,refs/stash,refs/heads/**,refs/remotes/**}'));
this._disposable = Disposable.from(
watcher,
watcher.onDidChange(this.onRepositoryChanged, this),
@ -121,7 +122,7 @@ export class Repository extends Disposable {
if (!initializing) {
this._remotes = undefined;
this.fireChange(RepositoryChange.RemotesCache);
this.fireChange(RepositoryChange.Remotes);
}
}
}
@ -134,18 +135,31 @@ export class Repository extends Disposable {
}
private onRepositoryChanged(uri: Uri) {
if (uri !== undefined && uri.path.endsWith('ref/stash')) {
if (uri !== undefined && uri.path.endsWith('refs/stash')) {
this.fireChange(RepositoryChange.Stashes);
return;
}
this.onAnyRepositoryChanged();
if (uri !== undefined && uri.path.endsWith('refs/remotes')) {
this._remotes = undefined;
this.fireChange(RepositoryChange.Remotes);
return;
}
if (uri !== undefined && uri.path.endsWith('config')) {
this._remotes = undefined;
this.fireChange(RepositoryChange.Config, RepositoryChange.Remotes);
return;
}
this.onAnyRepositoryChanged();
this.fireChange(RepositoryChange.Repository);
}
private fireChange(reason: RepositoryChange) {
private fireChange(...reasons: RepositoryChange[]) {
if (this._fireChangeDebounced === undefined) {
this._fireChangeDebounced = Functions.debounce(this.fireChangeCore, 250);
}
@ -156,8 +170,10 @@ export class Repository extends Disposable {
const e = this._pendingChanges.repo;
if (!e.changes.includes(reason)) {
e.changes.push(reason);
for (const reason of reasons) {
if (!e.changes.includes(reason)) {
e.changes.push(reason);
}
}
if (this._suspended) return;

Yükleniyor…
İptal
Kaydet