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

Commit

Permalink
Merge branch 'master' into fixes/unlock-context-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
StanleyGoldman authored Jun 28, 2017
2 parents 36bf23d + 0c83f0a commit 1076e8a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/GitHub.Api/Application/ApplicationManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}))
Expand Down
3 changes: 3 additions & 0 deletions src/GitHub.Api/GitHub.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@
<Compile Include="$(SolutionDir)\script\src\MetricsService.cs">
<Link>Metrics\MetricsService.cs</Link>
</Compile>
<Compile Include="$(SolutionDir)\script\src\ApplicationInfo_Local.cs">
<Link>Properties\ApplicationInfo_Local.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\submodules\dotnet-httpClient35\System.Net.Http\System.Net.Http-net_3_5.csproj">
Expand Down
6 changes: 3 additions & 3 deletions src/GitHub.Api/Helpers/AssemblyResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -21,15 +21,15 @@ 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(
String.Format("GitHub.Unity.{0}{1}.{2}", type, os != "" ? "." + os : os, resource));
if (stream != null)
return destinationPath.Combine(resource).WriteAllBytes(stream.ToByteArray());

return new NPath(type).Combine(os, resource);
return environment.ExtensionInstallPath.Combine(type, os, resource);
}
}
}
4 changes: 2 additions & 2 deletions src/GitHub.Api/Installer/GitInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public Task<bool> SetupGitIfNeeded(NPath tempPath, IProgress<float> 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());
Expand Down Expand Up @@ -228,7 +228,7 @@ public Task<bool> SetupGitLfsIfNeeded(NPath tempPath, IProgress<float> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -62,6 +62,16 @@ public IEnvironment Environment
}
}

private NPath DetermineInstallationPath()
{
// Juggling to find out where we got installed
var shim = ScriptableObject.CreateInstance<RunLocationShim>();
var script = MonoScript.FromScriptableObject(shim);
var scriptPath = AssetDatabase.GetAssetPath(script).ToNPath();
ScriptableObject.DestroyImmediate(shim);
return scriptPath.Parent;
}

public void Flush()
{
repositoryPath = Environment.RepositoryPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public static IView Open(Action<bool> onClose = null)

public override void OnGUI()
{
if (authView == null)
{
CreateViews();
}
authView.OnGUI();
}

Expand Down

0 comments on commit 1076e8a

Please sign in to comment.