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

Commit 5c1652c

Browse files
authored
Merge pull request #159 from github-for-unity/fixes/move-cache
Moving caches to library folder
2 parents 816f0ce + fab184a commit 5c1652c

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

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

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ public bool FirstRun
2121
return val;
2222
}
2323
}
24-
25-
[SerializeField] private string createdDate;
26-
public string CreatedDate
27-
{
28-
get { return createdDate; }
29-
}
3024
}
3125

3226
sealed class EnvironmentCache : ScriptObjectSingleton<EnvironmentCache>
@@ -83,15 +77,14 @@ public void Flush()
8377
}
8478
}
8579

86-
[Location("cache/branches.yaml", LocationAttribute.Location.UserFolder)]
80+
[Location("cache/branches.yaml", LocationAttribute.Location.LibraryFolder)]
8781
sealed class BranchCache : ScriptObjectSingleton<BranchCache>, IBranchCache
8882
{
8983
[SerializeField] private List<GitBranch> localBranches;
9084
[SerializeField] private List<GitBranch> remoteBranches;
91-
[SerializeField] private List<GitBranch> test;
85+
9286
public BranchCache()
9387
{
94-
test = new List<GitBranch>() { new GitBranch("name", "tracking", false) };
9588
}
9689

9790
public List<GitBranch> LocalBranches
@@ -104,7 +97,6 @@ public List<GitBranch> LocalBranches
10497
}
10598
set
10699
{
107-
Logging.GetLogger().Debug("Saving branches {0}", value.Join(","));
108100
localBranches = value;
109101
Save(true);
110102
}
@@ -125,7 +117,7 @@ public List<GitBranch> RemoteBranches
125117
}
126118
}
127119

128-
[Location("views/branches.yaml", LocationAttribute.Location.UserFolder)]
120+
[Location("views/branches.yaml", LocationAttribute.Location.LibraryFolder)]
129121
sealed class Favourites : ScriptObjectSingleton<Favourites>
130122
{
131123
[SerializeField] private List<string> favouriteBranches;
@@ -174,4 +166,27 @@ public bool IsFavourite(string branchName)
174166
return FavouriteBranches.Contains(branchName);
175167
}
176168
}
169+
170+
[Location("cache/gitlog.yaml", LocationAttribute.Location.LibraryFolder)]
171+
sealed class GitLogCache : ScriptObjectSingleton<GitLogCache>
172+
{
173+
[SerializeField] private List<GitLogEntry> log;
174+
public GitLogCache()
175+
{}
176+
177+
public List<GitLogEntry> Log
178+
{
179+
get
180+
{
181+
if (log == null)
182+
log = new List<GitLogEntry>();
183+
return log;
184+
}
185+
set
186+
{
187+
log = value;
188+
Save(true);
189+
}
190+
}
191+
}
177192
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace GitHub.Unity
88
[AttributeUsage(AttributeTargets.Class)]
99
class LocationAttribute : Attribute
1010
{
11-
public enum Location { PreferencesFolder, ProjectFolder, UserFolder }
11+
public enum Location { PreferencesFolder, ProjectFolder, LibraryFolder, UserFolder }
1212
public string filepath { get; set; }
1313
public LocationAttribute(string relativePath, Location location)
1414
{
@@ -21,8 +21,8 @@ public LocationAttribute(string relativePath, Location location)
2121
filepath = InternalEditorUtility.unityPreferencesFolder + "/" + relativePath;
2222
else if (location == Location.UserFolder)
2323
filepath = EntryPoint.Environment.UserCachePath.Combine(relativePath).ToString(SlashMode.Forward);
24-
else
25-
filepath = relativePath;
24+
else if (location == Location.LibraryFolder)
25+
filepath = EntryPoint.Environment.UnityProjectPath.Combine("Library", "gfu", relativePath);
2626
}
2727
}
2828

0 commit comments

Comments
 (0)