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

Commit 4cb76ea

Browse files
Adding a default and checking more tests
1 parent 6f82c41 commit 4cb76ea

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1+
using System;
2+
13
namespace GitHub.Unity
24
{
5+
[Serializable]
36
public struct GitAheadBehindStatus
47
{
5-
public int Ahead;
6-
public int Behind;
8+
public static GitAheadBehindStatus Default = new GitAheadBehindStatus();
9+
10+
public int ahead;
11+
public int behind;
12+
13+
public GitAheadBehindStatus(int ahead, int behind)
14+
{
15+
this.ahead = ahead;
16+
this.behind = behind;
17+
}
18+
19+
public int Ahead => ahead;
20+
21+
public int Behind => behind;
722
}
823
}

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ public void UpdateGitAheadBehindStatus()
305305
}
306306
}).Start();
307307
}
308+
else
309+
{
310+
GitAheadBehindStatusUpdated?.Invoke(GitAheadBehindStatus.Default);
311+
}
308312
}
309313

310314
public void UpdateLocks()

src/GitHub.Api/OutputProcessors/GitAheadBehindStatusOutputProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public override void LineReceived(string line)
1414
var ahead = int.Parse(proc.ReadUntilWhitespace());
1515
var behind = int.Parse(proc.ReadToEnd());
1616

17-
RaiseOnEntry(new GitAheadBehindStatus { Ahead = ahead, Behind = behind });
17+
RaiseOnEntry(new GitAheadBehindStatus { ahead = ahead, behind = behind });
1818
}
1919
}
2020
}

src/tests/IntegrationTests/Events/RepositoryManagerTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,11 @@ await Initialize(TestRepoMasterCleanSynchronized, initializeRepository: false,
469469
repositoryManagerEvents.RemoteBranchesUpdated.WaitOne(Timeout).Should().BeTrue();
470470
repositoryManagerEvents.LocalBranchesUpdated.WaitOne(Timeout).Should().BeTrue();
471471
repositoryManagerEvents.GitLogUpdated.WaitOne(Timeout).Should().BeTrue();
472+
repositoryManagerEvents.GitAheadBehindStatusUpdated.WaitOne(Timeout).Should().BeTrue();
472473

473474
repositoryManagerListener.Received().OnIsBusyChanged(Args.Bool);
474475
repositoryManagerListener.Received().CurrentBranchUpdated(Args.NullableConfigBranch, Args.NullableConfigRemote);
475-
repositoryManagerListener.DidNotReceive().GitAheadBehindStatusUpdated(Args.GitAheadBehindStatus);
476+
repositoryManagerListener.Received().GitAheadBehindStatusUpdated(Args.GitAheadBehindStatus);
476477
repositoryManagerListener.DidNotReceive().GitStatusUpdated(Args.GitStatus);
477478
repositoryManagerListener.DidNotReceive().GitLocksUpdated(Args.GitLocks);
478479
repositoryManagerListener.Received().GitLogUpdated(Args.GitLogs);
@@ -492,10 +493,11 @@ await Initialize(TestRepoMasterCleanSynchronized, initializeRepository: false,
492493
repositoryManagerEvents.RemoteBranchesUpdated.WaitOne(Timeout).Should().BeTrue();
493494
repositoryManagerEvents.LocalBranchesUpdated.WaitOne(Timeout).Should().BeTrue();
494495
repositoryManagerEvents.GitLogUpdated.WaitOne(Timeout).Should().BeTrue();
496+
repositoryManagerEvents.GitAheadBehindStatusUpdated.WaitOne(Timeout).Should().BeTrue();
495497

496498
repositoryManagerListener.Received().OnIsBusyChanged(Args.Bool);
497499
repositoryManagerListener.Received().CurrentBranchUpdated(Args.NullableConfigBranch, Args.NullableConfigRemote);
498-
repositoryManagerListener.DidNotReceive().GitAheadBehindStatusUpdated(Args.GitAheadBehindStatus);
500+
repositoryManagerListener.Received().GitAheadBehindStatusUpdated(Args.GitAheadBehindStatus);
499501
repositoryManagerListener.DidNotReceive().GitStatusUpdated(Args.GitStatus);
500502
repositoryManagerListener.DidNotReceive().GitLocksUpdated(Args.GitLocks);
501503
repositoryManagerListener.Received().GitLogUpdated(Args.GitLogs);

0 commit comments

Comments
 (0)