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

Commit c4d5f61

Browse files
Merge branch 'master' into fixes/nested-meta-file
# Conflicts: # src/tests/UnitTests/SetUpFixture.cs
2 parents dc95c07 + 0f5db5f commit c4d5f61

File tree

102 files changed

+2447
-816
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2447
-816
lines changed

GitHub.Unity.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TaskSystem", "src\tests\Tas
2727
EndProject
2828
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "src\tests\TestApp\TestApp.csproj", "{08B87D2A-8CF1-4211-B7AA-5209F00F72F8}"
2929
EndProject
30+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestWebServer", "src\tests\TestWebServer\TestWebServer.csproj", "{3DD3451C-30FA-4294-A3A9-1E080342F867}"
31+
EndProject
3032
Global
3133
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3234
Debug|Any CPU = Debug|Any CPU
@@ -94,6 +96,12 @@ Global
9496
{08B87D2A-8CF1-4211-B7AA-5209F00F72F8}.dev|Any CPU.Build.0 = Debug|Any CPU
9597
{08B87D2A-8CF1-4211-B7AA-5209F00F72F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
9698
{08B87D2A-8CF1-4211-B7AA-5209F00F72F8}.Release|Any CPU.Build.0 = Release|Any CPU
99+
{3DD3451C-30FA-4294-A3A9-1E080342F867}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
100+
{3DD3451C-30FA-4294-A3A9-1E080342F867}.Debug|Any CPU.Build.0 = Debug|Any CPU
101+
{3DD3451C-30FA-4294-A3A9-1E080342F867}.dev|Any CPU.ActiveCfg = Debug|Any CPU
102+
{3DD3451C-30FA-4294-A3A9-1E080342F867}.dev|Any CPU.Build.0 = Debug|Any CPU
103+
{3DD3451C-30FA-4294-A3A9-1E080342F867}.Release|Any CPU.ActiveCfg = Release|Any CPU
104+
{3DD3451C-30FA-4294-A3A9-1E080342F867}.Release|Any CPU.Build.0 = Release|Any CPU
97105
EndGlobalSection
98106
GlobalSection(SolutionProperties) = preSolution
99107
HideSolutionNode = FALSE
@@ -106,5 +114,6 @@ Global
106114
{66A1D219-F61D-4AE4-9BD7-AAEB97276FFF} = {D17F1B4C-42DC-4E78-BCEF-9F239A084C4D}
107115
{1A382F40-FD9E-43E1-89C1-320073F35CE9} = {D17F1B4C-42DC-4E78-BCEF-9F239A084C4D}
108116
{08B87D2A-8CF1-4211-B7AA-5209F00F72F8} = {D17F1B4C-42DC-4E78-BCEF-9F239A084C4D}
117+
{3DD3451C-30FA-4294-A3A9-1E080342F867} = {D17F1B4C-42DC-4E78-BCEF-9F239A084C4D}
109118
EndGlobalSection
110119
EndGlobal

GitHub.Unity.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@
335335
</TypePattern>
336336
&lt;/Patterns&gt;</s:String>
337337
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
338+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=MD/@EntryIndexedValue">MD</s:String>
338339
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SSH/@EntryIndexedValue">SSH</s:String>
339340
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
340341
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ The GitHub for Unity extension brings [Git](https://git-scm.com/) and GitHub int
4747

4848
### Requirements
4949

50-
- Unity 5.4-2017.1
51-
- We've only tested the extension so far on Unity 5.4 to 2017.1. There's currently an blocker issue opened for 5.3 support, so we know it doesn't run there. There are some issues for 2017.2, so it may or may not run well on that version. Personal edition is fine.
50+
- Unity 5.4 or higher
51+
- There's currently an blocker issue opened for 5.3 support, so we know it doesn't run there. Personal edition is fine.
5252
- Git and Git LFS 2.x
5353

5454
#### Git on macOS

common/codeanalysis-debug.ruleset

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RuleSet Name="codeanalysis-small" Description="This ruleset only includes the rules we care about. I'll be adding new ones as we fix our codebase." ToolsVersion="14.0">
2+
<RuleSet Name="codeanalysis-debug" Description="This ruleset only includes the rules we care about. I'll be adding new ones as we fix our codebase." ToolsVersion="14.0">
33
<IncludeAll Action="Warning" />
44
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
55
<Rule Id="CA1000" Action="None" />
@@ -86,7 +86,6 @@
8686
<Rule Id="CA1308" Action="None" />
8787
<Rule Id="CA1309" Action="None" />
8888
<Rule Id="CA1820" Action="None" />
89-
<Rule Id="CA1823" Action="None" />
9089

9190
<!-- serialization -->
9291
<Rule Id="CA2237" Action="None" />

script

src/GitHub.Api/Application/ApiClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Threading.Tasks;
55
using Octokit;
6+
using GitHub.Logging;
67
using System.Runtime.Serialization;
78

89
namespace GitHub.Unity
@@ -17,10 +18,10 @@ public static IApiClient Create(UriString repositoryUrl, IKeychain keychain)
1718
var hostAddress = HostAddress.Create(repositoryUrl);
1819

1920
return new ApiClient(repositoryUrl, keychain,
20-
new GitHubClient(AppConfiguration.ProductHeader, credentialStore, hostAddress.ApiUri));
21+
new GitHubClient(ApplicationConfiguration.ProductHeader, credentialStore, hostAddress.ApiUri));
2122
}
2223

23-
private static readonly ILogging logger = Logging.GetLogger<ApiClient>();
24+
private static readonly ILogging logger = LogHelper.GetLogger<ApiClient>();
2425
public HostAddress HostAddress { get; }
2526
public UriString OriginalUrl { get; }
2627

src/GitHub.Api/Application/AppConfiguration.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Reflection;
2+
using Octokit;
3+
4+
namespace GitHub.Unity
5+
{
6+
public static class ApplicationConfiguration
7+
{
8+
public const int DefaultWebTimeout = 3000;
9+
10+
static ApplicationConfiguration()
11+
{
12+
var executingAssembly = typeof(ApplicationConfiguration).Assembly;
13+
AssemblyName = executingAssembly.GetName();
14+
ProductHeader = new ProductHeaderValue(ApplicationInfo.ApplicationSafeName, AssemblyName.Version.ToString());
15+
}
16+
17+
/// <summary>
18+
/// The currently executing assembly.
19+
/// </summary>
20+
public static AssemblyName AssemblyName { get; }
21+
22+
/// <summary>
23+
/// The product header used in the user agent.
24+
/// </summary>
25+
public static ProductHeaderValue ProductHeader { get; private set; }
26+
27+
public static int WebTimeout { get; set; } = DefaultWebTimeout;
28+
}
29+
}

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 73 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
using System.Linq;
33
using System.Threading;
44
using System.Threading.Tasks;
5-
using Octokit;
65
using System.Collections.Generic;
6+
using GitHub.Logging;
77

88
namespace GitHub.Unity
99
{
1010
abstract class ApplicationManagerBase : IApplicationManager
1111
{
12-
protected static ILogging Logger { get; } = Logging.GetLogger<IApplicationManager>();
12+
protected static ILogging Logger { get; } = LogHelper.GetLogger<IApplicationManager>();
1313

1414
private RepositoryManager repositoryManager;
1515

@@ -36,49 +36,49 @@ protected void Initialize()
3636
LocalSettings.Initialize();
3737
SystemSettings.Initialize();
3838

39-
Logging.TracingEnabled = UserSettings.Get(Constants.TraceLoggingKey, false);
39+
LogHelper.TracingEnabled = UserSettings.Get(Constants.TraceLoggingKey, false);
4040
ProcessManager = new ProcessManager(Environment, Platform.GitEnvironment, CancellationToken);
4141
Platform.Initialize(ProcessManager, TaskManager);
42-
GitClient = new GitClient(Environment, ProcessManager, TaskManager);
42+
GitClient = new GitClient(Environment, ProcessManager, TaskManager.Token);
4343
SetupMetrics();
4444
}
4545

4646
public void Run(bool firstRun)
47-
{
48-
new ActionTask(SetupGit())
49-
.Then(RestartRepository)
50-
.ThenInUI(InitializeUI)
51-
.Start();
52-
}
53-
54-
private async Task SetupGit()
5547
{
5648
Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory);
5749

58-
if (Environment.GitExecutablePath == null)
50+
var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();
51+
if (gitExecutablePath != null && gitExecutablePath.FileExists()) // we have a git path
5952
{
60-
Environment.GitExecutablePath = await DetermineGitExecutablePath();
61-
62-
Logger.Trace("Environment.GitExecutablePath \"{0}\" Exists:{1}", Environment.GitExecutablePath, Environment.GitExecutablePath.FileExists());
63-
64-
if (Environment.IsWindows)
65-
{
66-
var credentialHelper = await GitClient.GetConfig("credential.helper", GitConfigSource.Global).StartAwait();
67-
68-
if (!string.IsNullOrEmpty(credentialHelper))
69-
{
70-
Logger.Trace("Windows CredentialHelper: {0}", credentialHelper);
71-
}
72-
else
73-
{
74-
Logger.Warning("No Windows CredentialHeloper found: Setting to wincred");
75-
76-
await GitClient.SetConfig("credential.helper", "wincred", GitConfigSource.Global).StartAwait();
77-
}
78-
}
53+
Logger.Trace("Using git install path from settings: {0}", gitExecutablePath);
54+
InitializeEnvironment(gitExecutablePath);
55+
}
56+
else // we need to go find git
57+
{
58+
Logger.Trace("No git path found in settings");
59+
60+
var initEnvironmentTask = new ActionTask<NPath>(CancellationToken, (b, path) => InitializeEnvironment(path)) { Affinity = TaskAffinity.UI };
61+
var findExecTask = new FindExecTask("git", CancellationToken)
62+
.FinallyInUI((b, ex, path) => {
63+
if (b && path != null)
64+
{
65+
Logger.Trace("FindExecTask Success: {0}", path);
66+
InitializeEnvironment(gitExecutablePath);
67+
}
68+
else
69+
{
70+
Logger.Warning("FindExecTask Failure");
71+
Logger.Error("Git not found");
72+
}
73+
});
74+
75+
var applicationDataPath = Environment.GetSpecialFolder(System.Environment.SpecialFolder.LocalApplicationData).ToNPath();
76+
var installDetails = new GitInstallDetails(applicationDataPath, true);
77+
var gitInstaller = new GitInstaller(Environment, CancellationToken, installDetails);
78+
79+
// if successful, continue with environment initialization, otherwise try to find an existing git installation
80+
gitInstaller.SetupGitIfNeeded(initEnvironmentTask, findExecTask);
7981
}
80-
81-
Environment.User.Initialize(GitClient);
8282
}
8383

8484
public ITask InitializeRepository()
@@ -136,27 +136,6 @@ public void RestartRepository()
136136
}
137137
}
138138

139-
private async Task<NPath> DetermineGitExecutablePath(ProgressReport progress = null)
140-
{
141-
var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();
142-
if (gitExecutablePath != null && gitExecutablePath.FileExists())
143-
{
144-
Logger.Trace("Using git install path from settings");
145-
return gitExecutablePath;
146-
}
147-
148-
var gitInstaller = new GitInstaller(Environment, CancellationToken);
149-
var setupDone = await gitInstaller.SetupIfNeeded(progress?.Percentage, progress?.Remaining);
150-
if (setupDone)
151-
{
152-
Logger.Trace("Setup performed using new path");
153-
return gitInstaller.GitExecutablePath;
154-
}
155-
156-
Logger.Trace("Finding git install path");
157-
return await GitClient.FindGitInstallation().SafeAwait();
158-
}
159-
160139
protected void SetupMetrics(string unityVersion, bool firstRun)
161140
{
162141
Logger.Trace("Setup metrics");
@@ -187,6 +166,45 @@ protected void SetupMetrics(string unityVersion, bool firstRun)
187166
protected abstract void InitializeUI();
188167
protected abstract void SetProjectToTextSerialization();
189168

169+
/// <summary>
170+
/// Initialize environment after finding where git is. This needs to run on the main thread
171+
/// </summary>
172+
/// <param name="gitExecutablePath"></param>
173+
private void InitializeEnvironment(NPath gitExecutablePath)
174+
{
175+
var afterGitSetup = new ActionTask(CancellationToken, RestartRepository)
176+
.ThenInUI(InitializeUI);
177+
178+
Environment.GitExecutablePath = gitExecutablePath;
179+
Environment.User.Initialize(GitClient);
180+
181+
if (Environment.IsWindows)
182+
{
183+
GitClient
184+
.GetConfig("credential.helper", GitConfigSource.Global)
185+
.Then((b, credentialHelper) => {
186+
if (!string.IsNullOrEmpty(credentialHelper))
187+
{
188+
Logger.Trace("Windows CredentialHelper: {0}", credentialHelper);
189+
afterGitSetup.Start();
190+
}
191+
else
192+
{
193+
Logger.Warning("No Windows CredentialHeloper found: Setting to wincred");
194+
195+
GitClient.SetConfig("credential.helper", "wincred", GitConfigSource.Global)
196+
.Then(afterGitSetup)
197+
.Start();
198+
}
199+
})
200+
.Start();
201+
}
202+
else
203+
{
204+
afterGitSetup.Start();
205+
}
206+
}
207+
190208
private bool disposed = false;
191209
protected virtual void Dispose(bool disposing)
192210
{

src/GitHub.Api/Authentication/Keychain.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Threading.Tasks;
55
using Octokit;
6+
using GitHub.Logging;
67

78
namespace GitHub.Unity
89
{
@@ -64,7 +65,7 @@ class Keychain : IKeychain
6465
{
6566
const string ConnectionFile = "connections.json";
6667

67-
private readonly ILogging logger = Logging.GetLogger<Keychain>();
68+
private readonly ILogging logger = LogHelper.GetLogger<Keychain>();
6869

6970
private readonly ICredentialManager credentialManager;
7071
private readonly NPath cachePath;

0 commit comments

Comments
 (0)