Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 6426c2b

Browse files
committed
Broadcast global invalidations on setConfig for global values
1 parent 7a03565 commit 6426c2b

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

lib/models/repository-states/present.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@ export default class Present extends State {
103103
return true;
104104
}
105105

106-
acceptInvalidation(spec) {
106+
acceptInvalidation(spec, {globally} = {}) {
107107
this.cache.invalidate(spec());
108108
this.didUpdate();
109+
if (globally) {
110+
this.didGloballyInvalidate(spec);
111+
}
109112
}
110113

111114
invalidateCacheAfterFilesystemChange(events) {
@@ -524,6 +527,7 @@ export default class Present extends State {
524527
return this.invalidate(
525528
() => Keys.config.eachWithSetting(setting),
526529
() => this.git().setConfig(setting, value, options),
530+
{globally: options.global},
527531
);
528532
}
529533

@@ -931,14 +935,14 @@ export default class Present extends State {
931935
return this.cache;
932936
}
933937

934-
invalidate(spec, body) {
938+
invalidate(spec, body, options = {}) {
935939
return body().then(
936940
result => {
937-
this.acceptInvalidation(spec);
941+
this.acceptInvalidation(spec, options);
938942
return result;
939943
},
940944
err => {
941-
this.acceptInvalidation(spec);
945+
this.acceptInvalidation(spec, options);
942946
return Promise.reject(err);
943947
},
944948
);

lib/models/repository-states/state.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import RemoteSet from '../remote-set';
55
import {nullOperationStates} from '../operation-states';
66
import MultiFilePatch from '../patch/multi-file-patch';
77
import CompositeGitStrategy from '../../composite-git-strategy';
8+
import {Keys} from './cache/keys';
89

910
/**
1011
* Map of registered subclasses to allow states to transition to one another without circular dependencies.
@@ -215,6 +216,9 @@ export default class State {
215216
async setConfig(optionName, value, options) {
216217
await this.workdirlessGit().setConfig(optionName, value, options);
217218
this.didUpdate();
219+
if (options.global) {
220+
this.didGloballyInvalidate(() => Keys.config.eachWithSetting(optionName));
221+
}
218222
}
219223

220224
unsetConfig(option) {

0 commit comments

Comments
 (0)