From dd2d932666b2e533ea1492eba0f2865f17317a60 Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Wed, 28 Jun 2017 11:50:36 +0200 Subject: [PATCH 1/3] Loading resources was horribly horribly broken --- src/GitHub.Api/Application/ApplicationManagerBase.cs | 4 ++-- src/GitHub.Api/Helpers/AssemblyResources.cs | 6 +++--- src/GitHub.Api/Installer/GitInstaller.cs | 4 ++-- .../Assets/Editor/GitHub.Unity/ApplicationCache.cs | 12 +++++++++++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/GitHub.Api/Application/ApplicationManagerBase.cs b/src/GitHub.Api/Application/ApplicationManagerBase.cs index 219aec2d5..34c2fa9bc 100644 --- a/src/GitHub.Api/Application/ApplicationManagerBase.cs +++ b/src/GitHub.Api/Application/ApplicationManagerBase.cs @@ -107,8 +107,8 @@ public ITask InitializeRepository() .Then(GitClient.LfsInstall()) .ThenInUI(SetProjectToTextSerialization) .Then(new ActionTask(CancellationToken, _ => { - AssemblyResources.ToFile(ResourceType.Generic, ".gitignore", targetPath); - AssemblyResources.ToFile(ResourceType.Generic, ".gitattributes", targetPath); + AssemblyResources.ToFile(ResourceType.Generic, ".gitignore", targetPath, Environment); + AssemblyResources.ToFile(ResourceType.Generic, ".gitattributes", targetPath, Environment); assetsGitignore.CreateFile(); })) diff --git a/src/GitHub.Api/Helpers/AssemblyResources.cs b/src/GitHub.Api/Helpers/AssemblyResources.cs index c00c57cb2..28303eca8 100644 --- a/src/GitHub.Api/Helpers/AssemblyResources.cs +++ b/src/GitHub.Api/Helpers/AssemblyResources.cs @@ -12,7 +12,7 @@ enum ResourceType class AssemblyResources { - public static NPath ToFile(ResourceType resourceType, string resource, NPath destinationPath) + public static NPath ToFile(ResourceType resourceType, string resource, NPath destinationPath, IEnvironment environment) { var os = ""; if (resourceType == ResourceType.Platform) @@ -21,7 +21,7 @@ public static NPath ToFile(ResourceType resourceType, string resource, NPath des : DefaultEnvironment.OnLinux ? "linux" : "mac"; } - var type = resourceType == ResourceType.Icon ? "Icons" + var type = resourceType == ResourceType.Icon ? "IconsAndLogos" : resourceType == ResourceType.Platform ? "PlatformResources" : "Resources"; var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream( @@ -29,7 +29,7 @@ public static NPath ToFile(ResourceType resourceType, string resource, NPath des if (stream != null) return destinationPath.Combine(resource).WriteAllBytes(stream.ToByteArray()); - return new NPath(type).Combine(os, resource); + return environment.ExtensionInstallPath.Combine(type, os, resource); } } } \ No newline at end of file diff --git a/src/GitHub.Api/Installer/GitInstaller.cs b/src/GitHub.Api/Installer/GitInstaller.cs index d122f5cf8..414433c39 100644 --- a/src/GitHub.Api/Installer/GitInstaller.cs +++ b/src/GitHub.Api/Installer/GitInstaller.cs @@ -163,7 +163,7 @@ public Task SetupGitIfNeeded(NPath tempPath, IProgress zipFileProgr cancellationToken.ThrowIfCancellationRequested(); - var archiveFilePath = AssemblyResources.ToFile(ResourceType.Platform, GitZipFile, tempPath); + var archiveFilePath = AssemblyResources.ToFile(ResourceType.Platform, GitZipFile, tempPath, environment); if (!archiveFilePath.FileExists()) { logger.Warning("Archive \"{0}\" missing", archiveFilePath.ToString()); @@ -228,7 +228,7 @@ public Task SetupGitLfsIfNeeded(NPath tempPath, IProgress zipFilePr cancellationToken.ThrowIfCancellationRequested(); - var archiveFilePath = AssemblyResources.ToFile(ResourceType.Platform, GitLfsZipFile, tempPath); + var archiveFilePath = AssemblyResources.ToFile(ResourceType.Platform, GitLfsZipFile, tempPath, environment); if (!archiveFilePath.FileExists()) { logger.Warning("Archive \"{0}\" missing", archiveFilePath.ToString()); diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs index 5c21eee56..5239a77be 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs @@ -50,7 +50,7 @@ public IEnvironment Environment { unityAssetsPath = Application.dataPath; unityApplication = EditorApplication.applicationPath; - extensionInstallPath = AssetDatabase.GetAssetPath(this); + extensionInstallPath = DetermineInstallationPath(); unityVersion = Application.unityVersion; } environment.Initialize(unityVersion, extensionInstallPath.ToNPath(), unityApplication.ToNPath(), unityAssetsPath.ToNPath()); @@ -62,6 +62,16 @@ public IEnvironment Environment } } + private NPath DetermineInstallationPath() + { + // Juggling to find out where we got installed + var shim = ScriptableObject.CreateInstance(); + var script = MonoScript.FromScriptableObject(shim); + var scriptPath = AssetDatabase.GetAssetPath(script).ToNPath(); + ScriptableObject.DestroyImmediate(shim); + return scriptPath.Parent; + } + public void Flush() { repositoryPath = Environment.RepositoryPath; From 3ad9510bbfaba68418e1cddf162635c1a9575b87 Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Wed, 28 Jun 2017 15:18:01 +0200 Subject: [PATCH 2/3] Yeah we kinda need this --- src/GitHub.Api/GitHub.Api.csproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/GitHub.Api/GitHub.Api.csproj b/src/GitHub.Api/GitHub.Api.csproj index 874e7467e..995e310dd 100644 --- a/src/GitHub.Api/GitHub.Api.csproj +++ b/src/GitHub.Api/GitHub.Api.csproj @@ -239,6 +239,9 @@ Metrics\MetricsService.cs + + Properties\ApplicationInfo_Local.cs + From 72fb426c98f30415ac44c24e6c535b0c0960f5de Mon Sep 17 00:00:00 2001 From: Andreia Gaita Date: Wed, 28 Jun 2017 15:18:54 +0200 Subject: [PATCH 3/3] Fix initializing the auth view' --- .../Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs index e67c0662f..2b11f5b40 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs @@ -29,6 +29,10 @@ public static IView Open(Action onClose = null) public override void OnGUI() { + if (authView == null) + { + CreateViews(); + } authView.OnGUI(); }