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

Commit 742a1a3

Browse files
Isolating cache access to properties
1 parent 90535f2 commit 742a1a3

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/GitHub.Api/Git/Repository.cs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,9 @@ private void RepositoryManager_OnRemoteBranchListUpdated(IDictionary<string, Con
389389

390390
private void UpdateRemoteAndRemoteBranches()
391391
{
392-
cacheContainer.BranchCache.Remotes =
393-
cacheContainer.BranchCache.ConfigRemotes.Values.Select(GetGitRemote).ToArray();
392+
Remotes = ConfigRemotes.Values.Select(GetGitRemote).ToArray();
394393

395-
cacheContainer.BranchCache.RemoteBranches = cacheContainer
396-
.BranchCache.RemoteConfigBranches.Values.SelectMany(x => x.Values).Select(GetRemoteGitBranch).ToArray();
394+
RemoteBranches = RemoteConfigBranches.Values.SelectMany(x => x.Values).Select(GetRemoteGitBranch).ToArray();
397395
}
398396

399397
private void RepositoryManager_OnLocalBranchListUpdated(IDictionary<string, ConfigBranch> branches)
@@ -406,8 +404,7 @@ private void RepositoryManager_OnLocalBranchListUpdated(IDictionary<string, Conf
406404

407405
private void UpdateLocalBranches()
408406
{
409-
cacheContainer.BranchCache.LocalBranches = cacheContainer
410-
.BranchCache.LocalConfigBranches.Values.Select(GetLocalGitBranch).ToArray();
407+
LocalBranches = LocalConfigBranches.Values.Select(GetLocalGitBranch).ToArray();
411408
}
412409

413410
private void UpdateRepositoryInfo()
@@ -479,16 +476,34 @@ private static GitRemote GetGitRemote(ConfigRemote configRemote)
479476
return new GitRemote { Name = configRemote.Name, Url = configRemote.Url };
480477
}
481478

482-
public GitRemote[] Remotes => cacheContainer.BranchCache.Remotes;
479+
private IRemoteConfigBranchDictionary RemoteConfigBranches => cacheContainer.BranchCache.RemoteConfigBranches;
483480

484-
public GitBranch[] LocalBranches => cacheContainer.BranchCache.LocalBranches;
481+
private IConfigRemoteDictionary ConfigRemotes => cacheContainer.BranchCache.ConfigRemotes;
485482

486-
public GitBranch[] RemoteBranches => cacheContainer.BranchCache.RemoteBranches;
483+
private ILocalConfigBranchDictionary LocalConfigBranches => cacheContainer.BranchCache.LocalConfigBranches;
484+
485+
public GitRemote[] Remotes
486+
{
487+
get { return cacheContainer.BranchCache.Remotes; }
488+
set { cacheContainer.BranchCache.Remotes = value; }
489+
}
490+
491+
public GitBranch[] LocalBranches
492+
{
493+
get { return cacheContainer.BranchCache.LocalBranches; }
494+
set { cacheContainer.BranchCache.LocalBranches = value; }
495+
}
496+
497+
public GitBranch[] RemoteBranches
498+
{
499+
get { return cacheContainer.BranchCache.RemoteBranches; }
500+
set { cacheContainer.BranchCache.RemoteBranches = value; }
501+
}
487502

488503
private ConfigBranch? CurrentConfigBranch
489504
{
490505
get { return this.cacheContainer.BranchCache.CurentConfigBranch; }
491-
set { cacheContainer.BranchCache.CurentConfigBranch = value;}
506+
set { cacheContainer.BranchCache.CurentConfigBranch = value; }
492507
}
493508

494509
private ConfigRemote? CurrentConfigRemote

0 commit comments

Comments
 (0)