Skip to content

Commit b7be44e

Browse files
authored
GitHub - fix an issue with toggling branch protection setting (microsoft#182536)
* GitHub - fix an issue with toggling branch protection setting * 💄 Remove variable * Pull request feedback
1 parent 367899f commit b7be44e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

extensions/git/src/model.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class Model implements IBranchProtectionProviderRegistry, IRemoteSourcePu
152152
private _onDidChangePostCommitCommandsProviders = new EventEmitter<void>();
153153
readonly onDidChangePostCommitCommandsProviders = this._onDidChangePostCommitCommandsProviders.event;
154154

155-
private branchProtectionProviders = new Map<Uri, Set<BranchProtectionProvider>>();
155+
private branchProtectionProviders = new Map<string, Set<BranchProtectionProvider>>();
156156

157157
private _onDidChangeBranchProtectionProviders = new EventEmitter<Uri>();
158158
readonly onDidChangeBranchProtectionProviders = this._onDidChangeBranchProtectionProviders.event;
@@ -769,17 +769,17 @@ export class Model implements IBranchProtectionProviderRegistry, IRemoteSourcePu
769769
registerBranchProtectionProvider(root: Uri, provider: BranchProtectionProvider): Disposable {
770770
const providerDisposables: Disposable[] = [];
771771

772-
this.branchProtectionProviders.set(root, (this.branchProtectionProviders.get(root) ?? new Set()).add(provider));
772+
this.branchProtectionProviders.set(root.toString(), (this.branchProtectionProviders.get(root.toString()) ?? new Set()).add(provider));
773773
providerDisposables.push(provider.onDidChangeBranchProtection(uri => this._onDidChangeBranchProtectionProviders.fire(uri)));
774774

775775
this._onDidChangeBranchProtectionProviders.fire(root);
776776

777777
return toDisposable(() => {
778-
const providers = this.branchProtectionProviders.get(root);
778+
const providers = this.branchProtectionProviders.get(root.toString());
779779

780780
if (providers && providers.has(provider)) {
781781
providers.delete(provider);
782-
this.branchProtectionProviders.set(root, providers);
782+
this.branchProtectionProviders.set(root.toString(), providers);
783783
this._onDidChangeBranchProtectionProviders.fire(root);
784784
}
785785

@@ -788,7 +788,7 @@ export class Model implements IBranchProtectionProviderRegistry, IRemoteSourcePu
788788
}
789789

790790
getBranchProtectionProviders(root: Uri): BranchProtectionProvider[] {
791-
return [...(this.branchProtectionProviders.get(root) ?? new Set()).values()];
791+
return [...(this.branchProtectionProviders.get(root.toString()) ?? new Set()).values()];
792792
}
793793

794794
registerPostCommitCommandsProvider(provider: PostCommitCommandsProvider): Disposable {

extensions/git/src/repository.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,9 @@ export class Repository implements Disposable {
23852385
}
23862386
}
23872387

2388-
this.branchProtection.set(remote, matchers);
2388+
if (matchers.length !== 0) {
2389+
this.branchProtection.set(remote, matchers);
2390+
}
23892391
}
23902392
}
23912393

0 commit comments

Comments
 (0)