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

Commit 0b3643e

Browse files
committed
Merge fixes/repository-tests-are-borked into fixes/mac-path-variable-more
2 parents acfe268 + cb9a037 commit 0b3643e

File tree

6 files changed

+51
-56
lines changed

6 files changed

+51
-56
lines changed

src/GitHub.Api/Git/GitConfig.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,20 @@ public struct ConfigBranch
7979

8080
public string name;
8181
public ConfigRemote remote;
82+
public string trackingBranch;
8283

8384
public ConfigBranch(string name)
8485
{
8586
this.name = name;
87+
this.trackingBranch = null;
8688
remote = ConfigRemote.Default;
8789
}
8890

89-
public ConfigBranch(string name, ConfigRemote? remote)
91+
public ConfigBranch(string name, ConfigRemote? remote, string trackingBranch)
9092
{
9193
this.name = name;
9294
this.remote = remote ?? ConfigRemote.Default;
95+
this.trackingBranch = trackingBranch != null && trackingBranch.StartsWith("refs/heads") ? trackingBranch.Substring("refs/heads".Length + 1) : null;
9396
}
9497

9598
public override int GetHashCode()
@@ -137,6 +140,7 @@ public bool Equals(ConfigBranch other)
137140
public bool IsTracking => Remote.HasValue;
138141

139142
public string Name => name;
143+
public string TrackingBranch => trackingBranch;
140144

141145
public ConfigRemote? Remote => Equals(remote, ConfigRemote.Default) ? (ConfigRemote?) null : remote;
142146

@@ -189,7 +193,7 @@ public IEnumerable<ConfigBranch> GetBranches()
189193
return groups
190194
.Where(x => x.Key == "branch")
191195
.SelectMany(x => x.Value)
192-
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote"))));
196+
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote")), x.Value.TryGetString("merge")));
193197
}
194198

195199
public IEnumerable<ConfigRemote> GetRemotes()
@@ -217,7 +221,7 @@ public IEnumerable<ConfigRemote> GetRemotes()
217221
.Where(x => x.Key == "branch")
218222
.SelectMany(x => x.Value)
219223
.Where(x => x.Key == branch)
220-
.Select(x => new ConfigBranch(x.Key,GetRemote(x.Value.TryGetString("remote"))) as ConfigBranch?)
224+
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote")), x.Value.TryGetString("merge")) as ConfigBranch?)
221225
.FirstOrDefault();
222226
}
223227

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public void UpdateGitAheadBehindStatus()
348348
if (configBranch.HasValue && configBranch.Value.Remote.HasValue)
349349
{
350350
var name = configBranch.Value.Name;
351-
var trackingName = configBranch.Value.IsTracking ? configBranch.Value.Remote.Value.Name + "/" + name : "[None]";
351+
var trackingName = configBranch.Value.IsTracking ? configBranch.Value.Remote.Value.Name + "/" + configBranch.Value.TrackingBranch : "[None]";
352352

353353
var task = GitClient.AheadBehindStatus(name, trackingName)
354354
.Then((success, status) =>
@@ -491,6 +491,10 @@ private void WatcherOnLocalBranchesChanged()
491491
{
492492
Logger.Trace("WatcherOnLocalBranchesChanged");
493493
DataNeedsRefreshing?.Invoke(CacheType.Branches);
494+
// the watcher should tell us what branch has changed so we can fire this only
495+
// when the active branch has changed
496+
DataNeedsRefreshing?.Invoke(CacheType.GitLog);
497+
DataNeedsRefreshing?.Invoke(CacheType.GitAheadBehind);
494498
}
495499

496500
private void WatcherOnRepositoryCommitted()
@@ -520,6 +524,7 @@ private void WatcherOnHeadChanged()
520524
Logger.Trace("WatcherOnHeadChanged");
521525
DataNeedsRefreshing?.Invoke(CacheType.RepositoryInfo);
522526
DataNeedsRefreshing?.Invoke(CacheType.GitLog);
527+
DataNeedsRefreshing?.Invoke(CacheType.GitAheadBehind);
523528
}
524529

525530
private void WatcherOnIndexChanged()
@@ -577,7 +582,7 @@ private void UpdateRemoteBranches()
577582
.Select(x => x.RelativeTo(basedir))
578583
.Select(x => x.ToString(SlashMode.Forward)))
579584
{
580-
branchList.Add(branch, new ConfigBranch(branch, remotes[remote]));
585+
branchList.Add(branch, new ConfigBranch(branch, remotes[remote], null));
581586
}
582587

583588
remoteBranches.Add(remote, branchList);

src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ public void AddRemoteBranch(string remote, string branch)
590590
if (!branchList.ContainsKey(branch))
591591
{
592592
var now = DateTimeOffset.Now;
593-
branchList.Add(branch, new ConfigBranch(branch, ConfigRemotes[remote]));
593+
branchList.Add(branch, new ConfigBranch(branch, ConfigRemotes[remote], null));
594594
Logger.Trace("AddRemoteBranch {0} remote:{1} branch:{2} ", now, remote, branch);
595595
SaveData(now, true);
596596
}

src/tests/IntegrationTests/BaseIntegrationTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ public virtual void OnTearDown()
219219
{
220220
TaskManager.Dispose();
221221
Environment?.CacheContainer.Dispose();
222+
BranchesCache.Instance = null;
223+
GitAheadBehindCache.Instance = null;
224+
GitLocksCache.Instance = null;
225+
GitLogCache.Instance = null;
226+
GitStatusCache.Instance = null;
227+
GitUserCache.Instance = null;
228+
RepositoryInfoCache.Instance = null;
222229

223230
Logger.Debug("Deleting TestBasePath: {0}", TestBasePath.ToString());
224231
for (var i = 0; i < 5; i++)

src/tests/IntegrationTests/CachingClasses.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static T Instance
1919
CreateAndLoad();
2020
return instance;
2121
}
22+
set { instance = value; }
2223
}
2324

2425
protected ScriptObjectSingleton()
@@ -560,7 +561,7 @@ public void AddRemoteBranch(string remote, string branch)
560561
if (!branchList.ContainsKey(branch))
561562
{
562563
var now = DateTimeOffset.Now;
563-
branchList.Add(branch, new ConfigBranch(branch, ConfigRemotes[remote]));
564+
branchList.Add(branch, new ConfigBranch(branch, ConfigRemotes[remote], null));
564565
Logger.Trace("AddRemoteBranch {0} remote:{1} branch:{2} ", now, remote, branch);
565566
SaveData(now, true);
566567
}

0 commit comments

Comments
 (0)