From b3e05d60d1be749e83c1995e4c6af30577c36838 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Mon, 31 Jul 2017 16:56:29 -0400 Subject: [PATCH 1/2] Moving caches to library folder --- .../Assets/Editor/GitHub.Unity/ApplicationCache.cs | 14 +++----------- .../Editor/GitHub.Unity/ScriptObjectSingleton.cs | 6 +++--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs index 5239a77be..e6b474c07 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs @@ -21,12 +21,6 @@ public bool FirstRun return val; } } - - [SerializeField] private string createdDate; - public string CreatedDate - { - get { return createdDate; } - } } sealed class EnvironmentCache : ScriptObjectSingleton @@ -83,15 +77,14 @@ public void Flush() } } - [Location("cache/branches.yaml", LocationAttribute.Location.UserFolder)] + [Location("cache/branches.yaml", LocationAttribute.Location.LibraryFolder)] sealed class BranchCache : ScriptObjectSingleton, IBranchCache { [SerializeField] private List localBranches; [SerializeField] private List remoteBranches; - [SerializeField] private List test; + public BranchCache() { - test = new List() { new GitBranch("name", "tracking", false) }; } public List LocalBranches @@ -104,7 +97,6 @@ public List LocalBranches } set { - Logging.GetLogger().Debug("Saving branches {0}", value.Join(",")); localBranches = value; Save(true); } @@ -125,7 +117,7 @@ public List RemoteBranches } } - [Location("views/branches.yaml", LocationAttribute.Location.UserFolder)] + [Location("views/branches.yaml", LocationAttribute.Location.LibraryFolder)] sealed class Favourites : ScriptObjectSingleton { [SerializeField] private List favouriteBranches; diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/ScriptObjectSingleton.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/ScriptObjectSingleton.cs index fcf09c3cd..f6ec083b8 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/ScriptObjectSingleton.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/ScriptObjectSingleton.cs @@ -8,7 +8,7 @@ namespace GitHub.Unity [AttributeUsage(AttributeTargets.Class)] class LocationAttribute : Attribute { - public enum Location { PreferencesFolder, ProjectFolder, UserFolder } + public enum Location { PreferencesFolder, ProjectFolder, LibraryFolder, UserFolder } public string filepath { get; set; } public LocationAttribute(string relativePath, Location location) { @@ -21,8 +21,8 @@ public LocationAttribute(string relativePath, Location location) filepath = InternalEditorUtility.unityPreferencesFolder + "/" + relativePath; else if (location == Location.UserFolder) filepath = EntryPoint.Environment.UserCachePath.Combine(relativePath).ToString(SlashMode.Forward); - else - filepath = relativePath; + else if (location == Location.LibraryFolder) + filepath = EntryPoint.Environment.UnityProjectPath.Combine("Library", "gfu", relativePath); } } From fab184aa606d24373d9e6f58e6f89b103f80e7f9 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Tue, 1 Aug 2017 07:50:40 -0400 Subject: [PATCH 2/2] Adding a cache for the git log data --- .../Editor/GitHub.Unity/ApplicationCache.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs index e6b474c07..360dab5b7 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs @@ -166,4 +166,27 @@ public bool IsFavourite(string branchName) return FavouriteBranches.Contains(branchName); } } + + [Location("cache/gitlog.yaml", LocationAttribute.Location.LibraryFolder)] + sealed class GitLogCache : ScriptObjectSingleton + { + [SerializeField] private List log; + public GitLogCache() + {} + + public List Log + { + get + { + if (log == null) + log = new List(); + return log; + } + set + { + log = value; + Save(true); + } + } + } }