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

Commit 31533c8

Browse files
Merge branch 'master' into fixes/update-after-push
2 parents 228bf07 + 44652ab commit 31533c8

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

src/GitHub.Api/Git/GitRemote.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public enum GitRemoteFunction
1414
[Serializable]
1515
public struct GitRemote
1616
{
17-
public static GitRemote Default = new GitRemote();
17+
public static GitRemote Default = new GitRemote(String.Empty, String.Empty, String.Empty, GitRemoteFunction.Unknown, string.Empty, string.Empty, string.Empty);
1818

1919
public string name;
2020
public string url;

src/GitHub.Api/Git/Repository.cs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void Initialize(IRepositoryManager initRepositoryManager)
5151
repositoryManager.GitStatusUpdated += RepositoryManagerOnGitStatusUpdated;
5252
repositoryManager.GitAheadBehindStatusUpdated += RepositoryManagerOnGitAheadBehindStatusUpdated;
5353
repositoryManager.GitLogUpdated += RepositoryManagerOnGitLogUpdated;
54+
repositoryManager.GitLocksUpdated += RepositoryManagerOnGitLocksUpdated;
5455
repositoryManager.LocalBranchesUpdated += RepositoryManagerOnLocalBranchesUpdated;
5556
repositoryManager.RemoteBranchesUpdated += RepositoryManagerOnRemoteBranchesUpdated;
5657
}
@@ -268,7 +269,7 @@ private void CacheContainer_OnCacheInvalidated(CacheType cacheType)
268269
break;
269270

270271
case CacheType.GitLocksCache:
271-
repositoryManager?.UpdateLocks();
272+
UpdateLocks();
272273
break;
273274

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

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

364365
if (!Nullable.Equals(CurrentConfigRemote, remote))
365366
{
366-
CurrentConfigRemote = remote;
367-
CurrentRemote = GetGitRemote(remote.Value);
368-
ClearRepositoryInfo();
367+
CurrentConfigRemote = remote;
368+
CurrentRemote = remote.HasValue ? (GitRemote?)GetGitRemote(remote.Value) : null;
369+
ClearRepositoryInfo();
369370
}
370371
}) { Affinity = TaskAffinity.UI }.Start();
371372
}
@@ -395,6 +396,14 @@ private void RepositoryManagerOnGitLogUpdated(List<GitLogEntry> gitLogEntries)
395396
}) { Affinity = TaskAffinity.UI }.Start();
396397
}
397398

399+
private void RepositoryManagerOnGitLocksUpdated(List<GitLock> gitLocks)
400+
{
401+
new ActionTask(CancellationToken.None, () => {
402+
CurrentLocks = gitLocks;
403+
})
404+
{ Affinity = TaskAffinity.UI }.Start();
405+
}
406+
398407
private void RepositoryManagerOnRemoteBranchesUpdated(Dictionary<string, ConfigRemote> remotes,
399408
Dictionary<string, Dictionary<string, ConfigBranch>> branches)
400409
{
@@ -419,6 +428,14 @@ private void RepositoryManagerOnLocalBranchesUpdated(Dictionary<string, ConfigBr
419428
}) { Affinity = TaskAffinity.UI }.Start();
420429
}
421430

431+
private void UpdateLocks()
432+
{
433+
if (CurrentRemote.HasValue)
434+
{
435+
repositoryManager?.UpdateLocks();
436+
}
437+
}
438+
422439
private void UpdateLocalBranches()
423440
{
424441
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
@@ -249,13 +249,13 @@ public ITask CreateBranch(string branch, string baseBranch)
249249
public ITask LockFile(string file)
250250
{
251251
var task = GitClient.Lock(file);
252-
return HookupHandlers(task, true, false);
252+
return HookupHandlers(task, true, false).Then(UpdateLocks);
253253
}
254254

255255
public ITask UnlockFile(string file, bool force)
256256
{
257257
var task = GitClient.Unlock(file, force);
258-
return HookupHandlers(task, true, false);
258+
return HookupHandlers(task, true, false).Then(UpdateLocks);
259259
}
260260

261261
public void UpdateGitLog()

0 commit comments

Comments
 (0)