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

Commit abeacbe

Browse files
authored
Merge pull request #634 from github-for-unity/releases/0.30
0.30 beta 1 release
2 parents ed310f0 + ace0030 commit abeacbe

35 files changed

+316
-221
lines changed

common/SolutionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
namespace System
3232
{
3333
internal static class AssemblyVersionInformation {
34-
internal const string Version = "0.30.0";
34+
internal const string Version = "0.30.3";
3535
}
3636
}

common/properties.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<!-- Build flags -->
44
<PropertyGroup>
55
<BuildType Condition="Exists('$(SolutionDir)script\src\MetricsService.cs')">Internal</BuildType>
6+
<BuildDefs Condition="Exists('$(SolutionDir)script\src\MetricsService.cs')">ENABLE_METRICS</BuildDefs>
67

78
<UnityDir Condition="$(UnityDir) == '' and Exists('$(SolutionDir)\script\lib\UnityEditor.dll')">$(SolutionDir)\script\lib\</UnityDir>
89
<UnityDir Condition="$(UnityDir) == '' and Exists('$(SolutionDir)\lib\UnityEditor.dll')">$(SolutionDir)\lib\</UnityDir>

src/GitHub.Api/Application/ApplicationInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace GitHub.Unity
44
static partial class ApplicationInfo
55
{
66
#if DEBUG
7-
public const string ApplicationName = "GitHubUnityDebug";
7+
public const string ApplicationName = "GitHub for Unity Debug";
88
public const string ApplicationProvider = "GitHub";
99
#else
1010
public const string ApplicationName = "GitHubUnity";

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -54,48 +54,52 @@ public void Run(bool firstRun)
5454
{
5555
Logger.Trace("Run - CurrentDirectory {0}", NPath.CurrentDirectory);
5656

57-
isBusy = true;
57+
var initEnvironmentTask = new ActionTask<NPath>(CancellationToken,
58+
(_, path) => InitializeEnvironment(path))
59+
{ Affinity = TaskAffinity.UI };
5860

59-
var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();
60-
if (gitExecutablePath.HasValue && gitExecutablePath.Value.FileExists()) // we have a git path
61-
{
62-
Logger.Trace("Using git install path from settings: {0}", gitExecutablePath);
63-
InitializeEnvironment(gitExecutablePath.Value);
64-
}
65-
else // we need to go find git
66-
{
67-
Logger.Trace("No git path found in settings");
61+
isBusy = true;
6862

69-
var initEnvironmentTask = new ActionTask<NPath>(CancellationToken,
70-
(b, path) => InitializeEnvironment(path)) { Affinity = TaskAffinity.UI };
71-
var findExecTask = new FindExecTask("git", CancellationToken)
72-
.FinallyInUI((b, ex, path) =>
63+
var octorunInstaller = new OctorunInstaller(Environment, TaskManager);
64+
var setupTask = octorunInstaller
65+
.SetupOctorunIfNeeded()
66+
.Then((s, octorunPath) =>
7367
{
74-
if (b && path.IsInitialized)
75-
{
76-
//Logger.Trace("FindExecTask Success: {0}", path);
77-
InitializeEnvironment(path);
78-
}
79-
else
80-
{
81-
//Logger.Warning("FindExecTask Failure");
82-
Logger.Error("Git not found");
83-
}
68+
Environment.OctorunScriptPath = octorunPath;
8469
});
8570

86-
var gitInstaller = new GitInstaller(Environment, CancellationToken);
71+
var initializeGitTask = new FuncTask<NPath>(CancellationToken, () =>
72+
{
73+
var gitExecutablePath = SystemSettings.Get(Constants.GitInstallPathKey)?.ToNPath();
74+
if (gitExecutablePath.HasValue && gitExecutablePath.Value.FileExists()) // we have a git path
75+
{
76+
Logger.Trace("Using git install path from settings: {0}", gitExecutablePath);
77+
return gitExecutablePath.Value;
78+
}
79+
return NPath.Default;
80+
});
8781

88-
// if successful, continue with environment initialization, otherwise try to find an existing git installation
89-
var setupTask = gitInstaller.SetupGitIfNeeded();
90-
setupTask.Progress(progressReporter.UpdateProgress);
91-
setupTask.OnEnd += (thisTask, result, success, exception) =>
82+
initializeGitTask.OnEnd += (t, path, _, __) =>
9283
{
93-
if (success && result.IsInitialized)
94-
thisTask.Then(initEnvironmentTask);
95-
else
96-
thisTask.Then(findExecTask);
84+
if (path.IsInitialized)
85+
return;
86+
87+
Logger.Trace("Using portable git");
88+
89+
var gitInstaller = new GitInstaller(Environment, ProcessManager, TaskManager);
90+
91+
var task = gitInstaller.SetupGitIfNeeded();
92+
task.Progress(progressReporter.UpdateProgress);
93+
task.OnEnd += (thisTask, result, success, exception) =>
94+
{
95+
thisTask.GetEndOfChain().Then(initEnvironmentTask, taskIsTopOfChain: true);
96+
};
97+
98+
// append installer task to top chain
99+
t.Then(task, taskIsTopOfChain: true);
97100
};
98-
}
101+
102+
setupTask.Then(initializeGitTask).Start();
99103
}
100104

101105
public ITask InitializeRepository()
@@ -170,6 +174,7 @@ protected void SetupMetrics(string unityVersion, bool firstRun)
170174
UserSettings.Set(Constants.GuidKey, id);
171175
}
172176

177+
#if ENABLE_METRICS
173178
var metricsService = new MetricsService(ProcessManager,
174179
TaskManager,
175180
Environment.FileSystem,
@@ -182,6 +187,7 @@ protected void SetupMetrics(string unityVersion, bool firstRun)
182187
{
183188
UsageTracker.IncrementLaunchCount();
184189
}
190+
#endif
185191
}
186192

187193
protected abstract void SetupMetrics();
@@ -195,13 +201,20 @@ protected void SetupMetrics(string unityVersion, bool firstRun)
195201
/// <param name="octorunScriptPath"></param>
196202
private void InitializeEnvironment(NPath gitExecutablePath)
197203
{
204+
SetupMetrics();
205+
206+
if (!gitExecutablePath.IsInitialized)
207+
{
208+
isBusy = false;
209+
return;
210+
}
211+
198212
Environment.GitExecutablePath = gitExecutablePath;
199213
Environment.User.Initialize(GitClient);
200214

201215
var afterGitSetup = new ActionTask(CancellationToken, RestartRepository)
202216
.ThenInUI(InitializeUI);
203217

204-
SetupMetrics();
205218
ITask task = afterGitSetup;
206219
if (Environment.IsWindows)
207220
{

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<DebugSymbols>true</DebugSymbols>
2323
<DebugType>full</DebugType>
2424
<Optimize>false</Optimize>
25-
<DefineConstants>DEBUG;TRACE</DefineConstants>
25+
<DefineConstants>DEBUG;TRACE;$(BuildDefs)</DefineConstants>
2626
<ErrorReport>prompt</ErrorReport>
2727
<WarningLevel>4</WarningLevel>
2828
<RunCodeAnalysis>true</RunCodeAnalysis>
@@ -32,7 +32,7 @@
3232
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3333
<DebugType>pdbonly</DebugType>
3434
<Optimize>true</Optimize>
35-
<DefineConstants>TRACE</DefineConstants>
35+
<DefineConstants>TRACE;$(BuildDefs)</DefineConstants>
3636
<ErrorReport>prompt</ErrorReport>
3737
<WarningLevel>4</WarningLevel>
3838
<BuildConfid>Release</BuildConfid>
@@ -44,7 +44,7 @@
4444
<DebugSymbols>true</DebugSymbols>
4545
<DebugType>full</DebugType>
4646
<Optimize>false</Optimize>
47-
<DefineConstants>TRACE;DEBUG;DEVELOPER_BUILD</DefineConstants>
47+
<DefineConstants>TRACE;DEBUG;DEVELOPER_BUILD;$(BuildDefs)</DefineConstants>
4848
<ErrorReport>prompt</ErrorReport>
4949
<WarningLevel>4</WarningLevel>
5050
<RunCodeAnalysis>false</RunCodeAnalysis>

src/GitHub.Api/Helpers/AssemblyResources.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static NPath ToFile(ResourceType resourceType, string resource, NPath des
3333
if (stream != null)
3434
return destinationPath.Combine(resource).WriteAllBytes(stream.ToByteArray());
3535

36-
return environment.ExtensionInstallPath.Combine(type, os, resource);
36+
return environment.ExtensionInstallPath.Combine(type, os, resource).Copy(destinationPath.Combine(resource));
3737
}
3838
}
3939
}

src/GitHub.Api/Installer/GitInstaller.cs

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Threading;
3-
using System.Threading.Tasks;
43
using GitHub.Logging;
54

65
namespace GitHub.Unity
@@ -11,59 +10,75 @@ class GitInstaller
1110
private readonly CancellationToken cancellationToken;
1211

1312
private readonly IEnvironment environment;
13+
private readonly IProcessManager processManager;
1414
private readonly GitInstallDetails installDetails;
1515
private readonly IZipHelper sharpZipLibHelper;
1616

17+
GitInstallationState installationState;
1718
ITask<NPath> installationTask;
1819

19-
public GitInstaller(IEnvironment environment, CancellationToken cancellationToken,
20+
public GitInstaller(IEnvironment environment, IProcessManager processManager,
21+
ITaskManager taskManager,
2022
GitInstallDetails installDetails = null)
2123
{
2224
this.environment = environment;
25+
this.processManager = processManager;
2326
this.sharpZipLibHelper = ZipHelper.Instance;
24-
this.cancellationToken = cancellationToken;
27+
this.cancellationToken = taskManager.Token;
2528
this.installDetails = installDetails ?? new GitInstallDetails(environment.UserCachePath, environment.IsWindows);
2629
}
2730

2831
public ITask<NPath> SetupGitIfNeeded()
2932
{
3033
//Logger.Trace("SetupGitIfNeeded");
3134

32-
installationTask = new FuncTask<GitInstallationState, NPath>(cancellationToken, (_, r) => installDetails.GitExecutablePath)
35+
installationTask = new FuncTask<NPath, NPath>(cancellationToken, (success, path) =>
36+
{
37+
return path;
38+
})
3339
{ Name = "Git Installation - Complete" };
3440
installationTask.OnStart += thisTask => thisTask.UpdateProgress(0, 100);
3541
installationTask.OnEnd += (thisTask, result, success, exception) => thisTask.UpdateProgress(100, 100);
3642

43+
ITask<NPath> startTask = null;
3744
if (!environment.IsWindows)
38-
return installationTask;
39-
40-
var startTask = new FuncTask<GitInstallationState>(cancellationToken, () =>
45+
{
46+
startTask = new FindExecTask("git", cancellationToken)
47+
.Configure(processManager);
48+
// we should doublecheck that system git is usable here
49+
installationState = new GitInstallationState
4150
{
42-
var state = VerifyGitInstallation();
43-
if (!state.GitIsValid && !state.GitLfsIsValid)
44-
state = GrabZipFromResources(state);
45-
else
46-
Logger.Trace("SetupGitIfNeeded: Skipped");
47-
return state;
48-
})
51+
GitIsValid = true,
52+
GitLfsIsValid = true
53+
};
54+
}
55+
else
56+
{
57+
startTask = new FuncTask<NPath>(cancellationToken, () =>
58+
{
59+
installationState = VerifyGitInstallation();
60+
if (!installationState.GitIsValid && !installationState.GitLfsIsValid)
61+
installationState = GrabZipFromResources(installationState);
62+
else
63+
Logger.Trace("SetupGitIfNeeded: Skipped");
64+
return installDetails.GitExecutablePath;
65+
})
4966
{ Name = "Git Installation - Extract" };
5067

68+
}
5169

52-
startTask.OnEnd += (thisTask, state, success, exception) =>
70+
startTask.OnEnd += (thisTask, path, success, exception) =>
5371
{
54-
if (!state.GitIsValid && !state.GitLfsIsValid)
72+
if (!installationState.GitIsValid && !installationState.GitLfsIsValid)
5573
{
56-
if (!state.GitZipExists || !state.GitLfsZipExists)
57-
thisTask = thisTask.Then(CreateDownloadTask(state));
58-
thisTask = thisTask.Then(ExtractPortableGit(state));
74+
if (!installationState.GitZipExists || !installationState.GitLfsZipExists)
75+
thisTask = thisTask.Then(CreateDownloadTask(installationState));
76+
thisTask = thisTask.Then(ExtractPortableGit(installationState));
5977
}
6078
thisTask.Then(installationTask);
6179
};
6280

63-
// we want to start the startTask and not the installationTask because the latter only gets
64-
// appended to the task chain when startTask ends, so calling Start() on it wouldn't work
65-
startTask.Start();
66-
return installationTask;
81+
return startTask;
6782
}
6883

6984
private GitInstallationState VerifyGitInstallation()
@@ -123,7 +138,7 @@ private GitInstallationState GrabZipFromResources(GitInstallationState state)
123138
return state;
124139
}
125140

126-
private ITask<GitInstallationState> CreateDownloadTask(GitInstallationState state)
141+
private ITask<NPath> CreateDownloadTask(GitInstallationState state)
127142
{
128143
var downloader = new Downloader();
129144
downloader.QueueDownload(installDetails.GitZipUrl, installDetails.GitZipMd5Url, installDetails.ZipPath);
@@ -133,11 +148,11 @@ private ITask<GitInstallationState> CreateDownloadTask(GitInstallationState stat
133148
state.GitZipExists = installDetails.GitZipPath.FileExists();
134149
state.GitLfsZipExists = installDetails.GitLfsZipPath.FileExists();
135150
installationTask.UpdateProgress(40, 100);
136-
return state;
151+
return installDetails.ZipPath;
137152
});
138153
}
139154

140-
private FuncTask<GitInstallationState> ExtractPortableGit(GitInstallationState state)
155+
private FuncTask<NPath> ExtractPortableGit(GitInstallationState state)
141156
{
142157
ITask<NPath> task = null;
143158
var tempZipExtractPath = NPath.CreateTempDirectory("git_zip_extract_zip_paths");
@@ -146,7 +161,7 @@ private FuncTask<GitInstallationState> ExtractPortableGit(GitInstallationState s
146161
if (!state.GitIsValid)
147162
{
148163
ITask<NPath> unzipTask = new UnzipTask(cancellationToken, installDetails.GitZipPath, gitExtractPath, sharpZipLibHelper,
149-
environment.FileSystem, GitInstallDetails.GitExtractedMD5);
164+
environment.FileSystem);
150165
unzipTask.Progress(p => installationTask.UpdateProgress(40 + (long)(20 * p.Percentage), 100, unzipTask.Name));
151166

152167
unzipTask = unzipTask.Then((s, path) =>
@@ -169,7 +184,7 @@ private FuncTask<GitInstallationState> ExtractPortableGit(GitInstallationState s
169184
if (!state.GitLfsIsValid)
170185
{
171186
ITask<NPath> unzipTask = new UnzipTask(cancellationToken, installDetails.GitLfsZipPath, gitLfsExtractPath, sharpZipLibHelper,
172-
environment.FileSystem, GitInstallDetails.GitLfsExtractedMD5);
187+
environment.FileSystem);
173188
unzipTask.Progress(p => installationTask.UpdateProgress(60 + (long)(20 * p.Percentage), 100, unzipTask.Name));
174189

175190
unzipTask = unzipTask.Then((s, path) =>
@@ -187,10 +202,10 @@ private FuncTask<GitInstallationState> ExtractPortableGit(GitInstallationState s
187202
task = task?.Then(unzipTask) ?? unzipTask;
188203
}
189204

190-
return task.Finally(new FuncTask<GitInstallationState>(cancellationToken, (success) =>
205+
return task.Finally(new FuncTask<NPath>(cancellationToken, (success) =>
191206
{
192207
tempZipExtractPath.DeleteIfExists();
193-
return state;
208+
return installDetails.GitInstallationPath;
194209
}));
195210
}
196211

src/GitHub.Api/Installer/IZipHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace GitHub.Unity
66
interface IZipHelper
77
{
88
bool Extract(string archive, string outFolder, CancellationToken cancellationToken,
9-
Func<long, long, bool> onProgress = null);
9+
Func<long, long, bool> onProgress);
1010
}
1111
}

0 commit comments

Comments
 (0)