Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/GitHub.Api/Cache/CacheContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ public void CheckAndRaiseEventsIfCacheNewer(CacheType cacheType, CacheUpdateEven

private void OnCacheUpdated(CacheType cacheType, DateTimeOffset datetime)
{
Logger.Trace("OnCacheUpdated cacheType:{0} datetime:{1}", cacheType, datetime);
CacheUpdated.SafeInvoke(cacheType, datetime);
}

private void OnCacheInvalidated(CacheType cacheType)
{
Logger.Trace("OnCacheInvalidated cacheType:{0}", cacheType);
CacheInvalidated.SafeInvoke(cacheType);
}

Expand Down
10 changes: 7 additions & 3 deletions src/GitHub.Api/Git/GitConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,20 @@ public struct ConfigBranch

public string name;
public ConfigRemote remote;
public string trackingBranch;

public ConfigBranch(string name)
{
this.name = name;
this.trackingBranch = null;
remote = ConfigRemote.Default;
}

public ConfigBranch(string name, ConfigRemote? remote)
public ConfigBranch(string name, ConfigRemote? remote, string trackingBranch)
{
this.name = name;
this.remote = remote ?? ConfigRemote.Default;
this.trackingBranch = trackingBranch != null && trackingBranch.StartsWith("refs/heads") ? trackingBranch.Substring("refs/heads".Length + 1) : null;
}

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

public string Name => name;
public string TrackingBranch => trackingBranch;

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

Expand Down Expand Up @@ -189,7 +193,7 @@ public IEnumerable<ConfigBranch> GetBranches()
return groups
.Where(x => x.Key == "branch")
.SelectMany(x => x.Value)
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote"))));
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote")), x.Value.TryGetString("merge")));
}

public IEnumerable<ConfigRemote> GetRemotes()
Expand Down Expand Up @@ -217,7 +221,7 @@ public IEnumerable<ConfigRemote> GetRemotes()
.Where(x => x.Key == "branch")
.SelectMany(x => x.Value)
.Where(x => x.Key == branch)
.Select(x => new ConfigBranch(x.Key,GetRemote(x.Value.TryGetString("remote"))) as ConfigBranch?)
.Select(x => new ConfigBranch(x.Key, GetRemote(x.Value.TryGetString("remote")), x.Value.TryGetString("merge")) as ConfigBranch?)
.FirstOrDefault();
}

Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.Api/Git/IRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GitHub.Unity
/// </summary>
public interface IRepository : IEquatable<IRepository>, IDisposable
{
void Initialize(IRepositoryManager repositoryManager, ITaskManager taskManager);
void Initialize(IRepositoryManager theRepositoryManager, ITaskManager theTaskManager);
void Start();

ITask CommitAllFiles(string message, string body);
Expand Down
11 changes: 5 additions & 6 deletions src/GitHub.Api/Git/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ public Repository(NPath localPath, ICacheContainer container)
};
}

public void Initialize(IRepositoryManager repositoryManager, ITaskManager taskManager)
public void Initialize(IRepositoryManager theRepositoryManager, ITaskManager theTaskManager)
{
//Logger.Trace("Initialize");
Guard.ArgumentNotNull(repositoryManager, nameof(repositoryManager));
Guard.ArgumentNotNull(taskManager, nameof(taskManager));
Guard.ArgumentNotNull(theRepositoryManager, nameof(theRepositoryManager));
Guard.ArgumentNotNull(theTaskManager, nameof(theTaskManager));

this.taskManager = taskManager;
this.repositoryManager = repositoryManager;
this.taskManager = theTaskManager;
this.repositoryManager = theRepositoryManager;
this.repositoryManager.CurrentBranchUpdated += RepositoryManagerOnCurrentBranchUpdated;
this.repositoryManager.GitStatusUpdated += RepositoryManagerOnGitStatusUpdated;
this.repositoryManager.GitAheadBehindStatusUpdated += RepositoryManagerOnGitAheadBehindStatusUpdated;
Expand Down Expand Up @@ -176,7 +176,6 @@ private void CacheHasBeenInvalidated(CacheType cacheType)
return;
}

Logger.Trace($"CacheInvalidated {cacheType.ToString()}");
switch (cacheType)
{
case CacheType.Branches:
Expand Down
9 changes: 7 additions & 2 deletions src/GitHub.Api/Git/RepositoryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public void UpdateGitAheadBehindStatus()
if (configBranch.HasValue && configBranch.Value.Remote.HasValue)
{
var name = configBranch.Value.Name;
var trackingName = configBranch.Value.IsTracking ? configBranch.Value.Remote.Value.Name + "/" + name : "[None]";
var trackingName = configBranch.Value.IsTracking ? configBranch.Value.Remote.Value.Name + "/" + configBranch.Value.TrackingBranch : "[None]";

var task = GitClient.AheadBehindStatus(name, trackingName)
.Then((success, status) =>
Expand Down Expand Up @@ -491,6 +491,10 @@ private void WatcherOnLocalBranchesChanged()
{
Logger.Trace("WatcherOnLocalBranchesChanged");
DataNeedsRefreshing?.Invoke(CacheType.Branches);
// the watcher should tell us what branch has changed so we can fire this only
// when the active branch has changed
DataNeedsRefreshing?.Invoke(CacheType.GitLog);
DataNeedsRefreshing?.Invoke(CacheType.GitAheadBehind);
}

private void WatcherOnRepositoryCommitted()
Expand Down Expand Up @@ -520,6 +524,7 @@ private void WatcherOnHeadChanged()
Logger.Trace("WatcherOnHeadChanged");
DataNeedsRefreshing?.Invoke(CacheType.RepositoryInfo);
DataNeedsRefreshing?.Invoke(CacheType.GitLog);
DataNeedsRefreshing?.Invoke(CacheType.GitAheadBehind);
}

private void WatcherOnIndexChanged()
Expand Down Expand Up @@ -577,7 +582,7 @@ private void UpdateRemoteBranches()
.Select(x => x.RelativeTo(basedir))
.Select(x => x.ToString(SlashMode.Forward)))
{
branchList.Add(branch, new ConfigBranch(branch, remotes[remote]));
branchList.Add(branch, new ConfigBranch(branch, remotes[remote], null));
}

remoteBranches.Add(remote, branchList);
Expand Down
23 changes: 11 additions & 12 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public GitBranch[] LocalBranches
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} localBranches:{1}", now, value);
Logger.Trace("{0} Updating LocalBranches: current:{1} new:{2}", now, localBranches, value);

var localBranchesIsNull = localBranches == null;
var valueIsNull = value == null;
Expand All @@ -512,7 +512,7 @@ public GitBranch[] RemoteBranches
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} remoteBranches:{1}", now, value);
Logger.Trace("{0} Updating RemoteBranches: current:{1} new:{2}", now, remoteBranches, value);

var remoteBranchesIsNull = remoteBranches == null;
var valueIsNull = value == null;
Expand All @@ -536,7 +536,7 @@ public GitRemote[] Remotes
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} remotes:{1}", now, value);
Logger.Trace("{0} Updating Remotes: current:{1} new:{2}", now, remotes, value);

var remotesIsNull = remotes == null;
var valueIsNull = value == null;
Expand Down Expand Up @@ -590,7 +590,7 @@ public void AddRemoteBranch(string remote, string branch)
if (!branchList.ContainsKey(branch))
{
var now = DateTimeOffset.Now;
branchList.Add(branch, new ConfigBranch(branch, ConfigRemotes[remote]));
branchList.Add(branch, new ConfigBranch(branch, ConfigRemotes[remote], null));
Logger.Trace("AddRemoteBranch {0} remote:{1} branch:{2} ", now, remote, branch);
SaveData(now, true);
}
Expand Down Expand Up @@ -671,7 +671,7 @@ public List<GitLogEntry> Log
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} gitLog:{1}", now, value);
Logger.Trace("{0} Updating Log: current:{1} new:{2}", now, log.Count, value.Count);

if (!log.SequenceEqual(value))
{
Expand Down Expand Up @@ -707,8 +707,7 @@ public int Ahead
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} ahead:{1}", now, value);

Logger.Trace("{0} Updating Ahead: current:{1} new:{2}", now, ahead, value);
if (ahead != value)
{
ahead = value;
Expand All @@ -731,7 +730,7 @@ public int Behind
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} behind:{1}", now, value);
Logger.Trace("{0} Updating Behind: current:{1} new:{2}", now, behind, value);

if (behind != value)
{
Expand Down Expand Up @@ -766,7 +765,7 @@ public List<GitStatusEntry> Entries
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} entries:{1}", now, value.Count);
Logger.Trace("{0} Updating Entries: current:{1} new:{2}", now, entries.Count, value.Count);

if (!entries.SequenceEqual(value))
{
Expand Down Expand Up @@ -801,7 +800,7 @@ public List<GitLock> GitLocks
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} gitLocks:{1}", now, value);
Logger.Trace("{0} Updating GitLocks: current:{1} new:{2}", now, gitLocks.Count, value.Count);

if (!gitLocks.SequenceEqual(value))
{
Expand Down Expand Up @@ -837,7 +836,7 @@ public string Name
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} Name:{1}", now, value);
Logger.Trace("{0} Updating Name: current:{1} new:{2}", now, gitName, value);

if (gitName != value)
{
Expand All @@ -861,7 +860,7 @@ public string Email
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} Email:{1}", now, value);
Logger.Trace("{0} Updating Email: current:{1} new:{2}", now, gitEmail, value);

if (gitEmail != value)
{
Expand Down
7 changes: 7 additions & 0 deletions src/tests/IntegrationTests/BaseIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ public virtual void OnTearDown()
{
TaskManager.Dispose();
Environment?.CacheContainer.Dispose();
BranchesCache.Instance = null;
GitAheadBehindCache.Instance = null;
GitLocksCache.Instance = null;
GitLogCache.Instance = null;
GitStatusCache.Instance = null;
GitUserCache.Instance = null;
RepositoryInfoCache.Instance = null;

Logger.Debug("Deleting TestBasePath: {0}", TestBasePath.ToString());
for (var i = 0; i < 5; i++)
Expand Down
23 changes: 12 additions & 11 deletions src/tests/IntegrationTests/CachingClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static T Instance
CreateAndLoad();
return instance;
}
set { instance = value; }
}

protected ScriptObjectSingleton()
Expand Down Expand Up @@ -458,7 +459,7 @@ public GitBranch[] LocalBranches
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} localBranches:{1}", now, value);
Logger.Trace("{0} Updating LocalBranches: current:{1} new:{2}", now, localBranches, value);

var localBranchesIsNull = localBranches == null;
var valueIsNull = value == null;
Expand All @@ -482,7 +483,7 @@ public GitBranch[] RemoteBranches
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} remoteBranches:{1}", now, value);
Logger.Trace("{0} Updating RemoteBranches: current:{1} new:{2}", now, remoteBranches, value);

var remoteBranchesIsNull = remoteBranches == null;
var valueIsNull = value == null;
Expand All @@ -506,7 +507,7 @@ public GitRemote[] Remotes
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} remotes:{1}", now, value);
Logger.Trace("{0} Updating Remotes: current:{1} new:{2}", now, remotes, value);

var remotesIsNull = remotes == null;
var valueIsNull = value == null;
Expand Down Expand Up @@ -560,7 +561,7 @@ public void AddRemoteBranch(string remote, string branch)
if (!branchList.ContainsKey(branch))
{
var now = DateTimeOffset.Now;
branchList.Add(branch, new ConfigBranch(branch, ConfigRemotes[remote]));
branchList.Add(branch, new ConfigBranch(branch, ConfigRemotes[remote], null));
Logger.Trace("AddRemoteBranch {0} remote:{1} branch:{2} ", now, remote, branch);
SaveData(now, true);
}
Expand Down Expand Up @@ -640,7 +641,7 @@ public List<GitLogEntry> Log
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} gitLog:{1}", now, value);
Logger.Trace("{0} Updating Log: current:{1} new:{2}", now, log.Count, value.Count);

if (!log.SequenceEqual(value))
{
Expand Down Expand Up @@ -675,7 +676,7 @@ public int Ahead
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} ahead:{1}", now, value);
Logger.Trace("{0} Updating Ahead: current:{1} new:{2}", now, ahead, value);

if (ahead != value)
{
Expand All @@ -699,7 +700,7 @@ public int Behind
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} behind:{1}", now, value);
Logger.Trace("{0} Updating Behind: current:{1} new:{2}", now, behind, value);

if (behind != value)
{
Expand Down Expand Up @@ -733,7 +734,7 @@ public List<GitStatusEntry> Entries
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} entries:{1}", now, value.Count);
Logger.Trace("{0} Updating Entries: current:{1} new:{2}", now, entries.Count, value.Count);

if (!entries.SequenceEqual(value))
{
Expand Down Expand Up @@ -767,7 +768,7 @@ public List<GitLock> GitLocks
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} gitLocks:{1}", now, value);
Logger.Trace("{0} Updating GitLocks: current:{1} new:{2}", now, gitLocks.Count, value.Count);

if (!gitLocks.SequenceEqual(value))
{
Expand Down Expand Up @@ -802,7 +803,7 @@ public string Name
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} Name:{1}", now, value);
Logger.Trace("{0} Updating Name: current:{1} new:{2}", now, gitName, value);

if (gitName != value)
{
Expand All @@ -826,7 +827,7 @@ public string Email
var now = DateTimeOffset.Now;
var isUpdated = false;

Logger.Trace("Updating: {0} Email:{1}", now, value);
Logger.Trace("{0} Updating Email: current:{1} new:{2}", now, gitEmail, value);

if (gitEmail != value)
{
Expand Down
Loading