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

Commit 44652ab

Browse files
Merge pull request #488 from github-for-unity/fixes/lfs-locks-update
Updating LFS locks list after lock operation
2 parents 931f7c4 + e3b2bbe commit 44652ab

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

src/GitHub.Api/Git/Repository.cs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public void Initialize(IRepositoryManager initRepositoryManager)
5050
repositoryManager.CurrentBranchUpdated += RepositoryManagerOnCurrentBranchUpdated;
5151
repositoryManager.GitStatusUpdated += RepositoryManagerOnGitStatusUpdated;
5252
repositoryManager.GitLogUpdated += RepositoryManagerOnGitLogUpdated;
53+
repositoryManager.GitLocksUpdated += RepositoryManagerOnGitLocksUpdated;
5354
repositoryManager.LocalBranchesUpdated += RepositoryManagerOnLocalBranchesUpdated;
5455
repositoryManager.RemoteBranchesUpdated += RepositoryManagerOnRemoteBranchesUpdated;
5556
}
@@ -267,7 +268,7 @@ private void CacheContainer_OnCacheInvalidated(CacheType cacheType)
267268
break;
268269

269270
case CacheType.GitLocksCache:
270-
repositoryManager?.UpdateLocks();
271+
UpdateLocks();
271272
break;
272273

273274
case CacheType.GitUserCache:
@@ -353,18 +354,18 @@ private void RepositoryManagerOnCurrentBranchUpdated(ConfigBranch? branch, Confi
353354
new ActionTask(CancellationToken.None, () => {
354355
if (!Nullable.Equals(CurrentConfigBranch, branch))
355356
{
356-
var currentBranch = branch != null ? (GitBranch?)GetLocalGitBranch(branch.Value) : null;
357+
var currentBranch = branch != null ? (GitBranch?)GetLocalGitBranch(branch.Value) : null;
357358

358-
CurrentConfigBranch = branch;
359-
CurrentBranch = currentBranch;
360-
UpdateLocalBranches();
359+
CurrentConfigBranch = branch;
360+
CurrentBranch = currentBranch;
361+
UpdateLocalBranches();
361362
}
362363

363364
if (!Nullable.Equals(CurrentConfigRemote, remote))
364365
{
365-
CurrentConfigRemote = remote;
366-
CurrentRemote = GetGitRemote(remote.Value);
367-
ClearRepositoryInfo();
366+
CurrentConfigRemote = remote;
367+
CurrentRemote = remote.HasValue ? (GitRemote?)GetGitRemote(remote.Value) : null;
368+
ClearRepositoryInfo();
368369
}
369370
}) { Affinity = TaskAffinity.UI }.Start();
370371
}
@@ -383,6 +384,14 @@ private void RepositoryManagerOnGitLogUpdated(List<GitLogEntry> gitLogEntries)
383384
}) { Affinity = TaskAffinity.UI }.Start();
384385
}
385386

387+
private void RepositoryManagerOnGitLocksUpdated(List<GitLock> gitLocks)
388+
{
389+
new ActionTask(CancellationToken.None, () => {
390+
CurrentLocks = gitLocks;
391+
})
392+
{ Affinity = TaskAffinity.UI }.Start();
393+
}
394+
386395
private void RepositoryManagerOnRemoteBranchesUpdated(Dictionary<string, ConfigRemote> remotes,
387396
Dictionary<string, Dictionary<string, ConfigBranch>> branches)
388397
{
@@ -401,6 +410,14 @@ private void RepositoryManagerOnLocalBranchesUpdated(Dictionary<string, ConfigBr
401410
}) { Affinity = TaskAffinity.UI }.Start();
402411
}
403412

413+
private void UpdateLocks()
414+
{
415+
if (CurrentRemote.HasValue)
416+
{
417+
repositoryManager?.UpdateLocks();
418+
}
419+
}
420+
404421
private void UpdateLocalBranches()
405422
{
406423
LocalBranches = LocalConfigBranches.Values.Select(GetLocalGitBranch).ToArray();

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,13 @@ public ITask CreateBranch(string branch, string baseBranch)
246246
public ITask LockFile(string file)
247247
{
248248
var task = GitClient.Lock(file);
249-
return HookupHandlers(task, true, false);
249+
return HookupHandlers(task, true, false).Then(UpdateLocks);
250250
}
251251

252252
public ITask UnlockFile(string file, bool force)
253253
{
254254
var task = GitClient.Unlock(file, force);
255-
return HookupHandlers(task, true, false);
255+
return HookupHandlers(task, true, false).Then(UpdateLocks);
256256
}
257257

258258
public void UpdateGitLog()

0 commit comments

Comments
 (0)