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

Commit b7453cc

Browse files
Merge branch 'master' into fixes/readme-pdf-in-package
2 parents 68eba95 + fb045a1 commit b7453cc

Some content is hidden

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

66 files changed

+1010
-305
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You can reach the team right here by opening a [new issue](https://github.com/gi
1313

1414
## Notices
1515

16-
This software is currently alpha quality. Please refer to the [list of known issues](https://github.com/github-for-unity/Unity/issues?q=is%3Aissue+is%3Aopen+label%3Abug), and make sure you have backups of your work before trying it out.
16+
Please refer to the [list of known issues](https://github.com/github-for-unity/Unity/issues?q=is%3Aissue+is%3Aopen+label%3Abug), and make sure you have backups of your work before trying it out.
1717

1818
From version 0.19 onwards, the location of the plugin has moved to `Assets/Plugins/GitHub`. If you have version 0.18 or lower, you need to delete the `Assets/Editor/GitHub` folder before you install newer versions. You should exit Unity and delete the folder from Explorer/Finder, as Unity will not unload native libraries while it's running. Also, remember to update your `.gitignore` file.
1919

common/SolutionInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ namespace System
3232
{
3333
internal static class AssemblyVersionInformation {
3434
// this is for the AssemblyVersion and AssemblyVersion attributes, which can't handle alphanumerics
35-
internal const string VersionForAssembly = "0.99.0";
35+
internal const string VersionForAssembly = "1.0.0";
3636
// Actual real version
37-
internal const string Version = "1.0.0.0-rc1";
37+
internal const string Version = "1.0.0";
3838
}
3939
}

src/GitHub.Api/Application/ApiClient.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,9 @@ public ApiClient(UriString hostUrl, IKeychain keychain, IProcessManager processM
4040
octorunScript: octorunScriptPath);
4141
}
4242

43-
public async Task Logout(UriString host)
43+
public ITask Logout(UriString host)
4444
{
45-
await LogoutInternal(host);
46-
}
47-
48-
private async Task LogoutInternal(UriString host)
49-
{
50-
await loginManager.Logout(host);
45+
return loginManager.Logout(host);
5146
}
5247

5348
public async Task CreateRepository(string name, string description, bool isPrivate, Action<GitHubRepository, Exception> callback, string organization = null)

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ abstract class ApplicationManagerBase : IApplicationManager
1212
protected static ILogging Logger { get; } = LogHelper.GetLogger<IApplicationManager>();
1313

1414
private RepositoryManager repositoryManager;
15-
private Progress progressReporter;
15+
private ProgressReporter progressReporter = new ProgressReporter();
16+
private Progress progress = new Progress(TaskBase.Default);
1617
protected bool isBusy;
1718
private bool firstRun;
1819
protected bool FirstRun { get { return firstRun; } set { firstRun = value; } }
@@ -27,13 +28,13 @@ public event Action<IProgress> OnProgress
2728

2829
public ApplicationManagerBase(SynchronizationContext synchronizationContext)
2930
{
30-
progressReporter = new Progress();
3131
SynchronizationContext = synchronizationContext;
3232
SynchronizationContext.SetSynchronizationContext(SynchronizationContext);
3333
ThreadingHelper.SetUIThread();
3434
UIScheduler = TaskScheduler.FromCurrentSynchronizationContext();
3535
ThreadingHelper.MainThreadScheduler = UIScheduler;
3636
TaskManager = new TaskManager(UIScheduler);
37+
progress.OnProgress += progressReporter.UpdateProgress;
3738
}
3839

3940
protected void Initialize()
@@ -51,6 +52,7 @@ protected void Initialize()
5152
public void Run()
5253
{
5354
isBusy = true;
55+
progress.UpdateProgress(0, 100, "Initializing...");
5456

5557
var thread = new Thread(() =>
5658
{
@@ -72,8 +74,13 @@ public void Run()
7274
}
7375
}
7476

75-
var installer = new GitInstaller(Environment, ProcessManager, CancellationToken)
76-
{ Progress = progressReporter };
77+
progress.UpdateProgress(20, 100, "Setting up octorun...");
78+
79+
Environment.OctorunScriptPath = new OctorunInstaller(Environment, TaskManager)
80+
.SetupOctorunIfNeeded();
81+
82+
progress.UpdateProgress(50, 100, "Setting up git...");
83+
7784
state = Environment.GitInstallationState;
7885
if (!state.GitIsValid && !state.GitLfsIsValid && FirstRun)
7986
{
@@ -88,6 +95,9 @@ public void Run()
8895
}
8996
}
9097

98+
99+
var installer = new GitInstaller(Environment, ProcessManager, CancellationToken);
100+
installer.Progress.OnProgress += progressReporter.UpdateProgress;
91101
if (state.GitIsValid && state.GitLfsIsValid)
92102
{
93103
if (firstRun)
@@ -100,25 +110,26 @@ public void Run()
100110
}
101111
}
102112

103-
Environment.OctorunScriptPath = new OctorunInstaller(Environment, TaskManager)
104-
.SetupOctorunIfNeeded();
105-
106113
if (!state.GitIsValid || !state.GitLfsIsValid)
107114
{
108115
state = installer.SetupGitIfNeeded();
109116
}
110117

111118
SetupGit(state);
112119

120+
progress.UpdateProgress(80, 100, "Initializing repository...");
121+
113122
if (state.GitIsValid && state.GitLfsIsValid)
114123
{
115124
RestartRepository();
116125
}
117126

127+
progress.UpdateProgress(100, 100, "Initialization failed");
118128
}
119129
catch (Exception ex)
120130
{
121131
Logger.Error(ex, "A problem ocurred setting up Git");
132+
progress.UpdateProgress(90, 100, "Initialization failed");
122133
}
123134

124135
new ActionTask<bool>(CancellationToken, (s, gitIsValid) =>
@@ -204,6 +215,7 @@ public void SetupGit(GitInstaller.GitInstallationState state)
204215
public void InitializeRepository()
205216
{
206217
isBusy = true;
218+
progress.UpdateProgress(0, 100, "Initializing...");
207219
var thread = new Thread(() =>
208220
{
209221
var success = true;
@@ -218,27 +230,37 @@ public void InitializeRepository()
218230
var filesForInitialCommit = new List<string> { gitignore, gitAttrs, assetsGitignore };
219231

220232
GitClient.Init().RunWithReturn(true);
233+
progress.UpdateProgress(10, 100, "Initializing...");
221234

222235
ConfigureMergeSettings();
236+
progress.UpdateProgress(20, 100, "Initializing...");
237+
223238
GitClient.LfsInstall().RunWithReturn(true);
239+
progress.UpdateProgress(30, 100, "Initializing...");
240+
224241
AssemblyResources.ToFile(ResourceType.Generic, ".gitignore", targetPath, Environment);
225242
AssemblyResources.ToFile(ResourceType.Generic, ".gitattributes", targetPath, Environment);
226243
assetsGitignore.CreateFile();
227244
GitClient.Add(filesForInitialCommit).RunWithReturn(true);
245+
progress.UpdateProgress(60, 100, "Initializing...");
228246
GitClient.Commit("Initial commit", null).RunWithReturn(true);
247+
progress.UpdateProgress(70, 100, "Initializing...");
229248
Environment.InitializeRepository();
230249
UsageTracker.IncrementProjectsInitialized();
231250
}
232251
catch (Exception ex)
233252
{
234253
Logger.Error(ex, "A problem ocurred initializing the repository");
254+
progress.UpdateProgress(90, 100, "Failed to initialize repository");
235255
success = false;
236256
}
237257

238258
if (success)
239259
{
260+
progress.UpdateProgress(90, 100, "Initializing...");
240261
RestartRepository();
241262
TaskManager.RunInUI(InitializeUI);
263+
progress.UpdateProgress(100, 100, "Initialized");
242264
}
243265
isBusy = false;
244266
});

src/GitHub.Api/Application/IApiClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Task CreateRepository(string name, string description, bool isPrivate,
1212
Task GetOrganizations(Action<Organization[]> onSuccess, Action<Exception> onError = null);
1313
Task Login(string username, string password, Action<LoginResult> need2faCode, Action<bool, string> result);
1414
Task ContinueLogin(LoginResult loginResult, string code);
15-
Task Logout(UriString host);
15+
ITask Logout(UriString host);
1616
Task GetCurrentUser(Action<GitHubUser> onSuccess, Action<Exception> onError = null);
1717
}
1818
}

src/GitHub.Api/Authentication/ILoginManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ interface ILoginManager
2525
/// </summary>
2626
/// <param name="hostAddress">The address of the server.</param>
2727
/// <inheritdoc/>
28-
Task Logout(UriString hostAddress);
28+
ITask Logout(UriString hostAddress);
2929
}
3030
}

src/GitHub.Api/Authentication/LoginManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ public async Task<LoginResultData> ContinueLogin(LoginResultData loginResultData
134134
}
135135

136136
/// <inheritdoc/>
137-
public async Task Logout(UriString hostAddress)
137+
public ITask Logout(UriString hostAddress)
138138
{
139139
Guard.ArgumentNotNull(hostAddress, nameof(hostAddress));
140140

141-
await new ActionTask(keychain.Clear(hostAddress, true)).StartAwait();
141+
return new ActionTask(keychain.Clear(hostAddress, true)) { Message = "Signing out" }.Start();
142142
}
143143

144144
private async Task<LoginResultData> TryLogin(

src/GitHub.Api/Cache/CacheContainer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public void InvalidateAll()
3030
{
3131
foreach (var cache in caches.Values)
3232
{
33-
// force an invalidation if the cache is valid, otherwise it will do it on its own
34-
if (cache.Value.ValidateData())
35-
cache.Value.InvalidateData();
33+
cache.Value.InvalidateData();
3634
}
3735
}
3836

src/GitHub.Api/Git/IRepository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ public interface IRepository : IEquatable<IRepository>, IDisposable, IBackedByCa
7878
ITask CreateBranch(string branch, string baseBranch);
7979
ITask SwitchBranch(string branch);
8080
void Refresh(CacheType cacheType);
81+
event Action<IProgress> OnProgress;
8182
}
8283
}

src/GitHub.Api/Git/Repository.cs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ sealed class Repository : IEquatable<Repository>, IRepository
2424
private string name;
2525
private HashSet<CacheType> cacheInvalidationRequests = new HashSet<CacheType>();
2626
private Dictionary<CacheType, Action<CacheUpdateEvent>> cacheUpdateEvents;
27+
private ProgressReporter progressReporter = new ProgressReporter();
2728

2829
public event Action<CacheUpdateEvent> LogChanged;
2930
public event Action<CacheUpdateEvent> TrackingStatusChanged;
@@ -35,6 +36,11 @@ sealed class Repository : IEquatable<Repository>, IRepository
3536
public event Action<CacheUpdateEvent> LocksChanged;
3637
public event Action<CacheUpdateEvent> RemoteBranchListChanged;
3738
public event Action<CacheUpdateEvent> LocalAndRemoteBranchListChanged;
39+
public event Action<IProgress> OnProgress
40+
{
41+
add { progressReporter.OnProgress += value; }
42+
remove { progressReporter.OnProgress -= value; }
43+
}
3844

3945
/// <summary>
4046
/// Initializes a new instance of the <see cref="Repository"/> class.
@@ -89,6 +95,15 @@ public void Initialize(IRepositoryManager theRepositoryManager, ITaskManager the
8995
this.repositoryManager.LocalBranchesUpdated += RepositoryManagerOnLocalBranchesUpdated;
9096
this.repositoryManager.RemoteBranchesUpdated += RepositoryManagerOnRemoteBranchesUpdated;
9197
this.repositoryManager.DataNeedsRefreshing += RefreshCache;
98+
try
99+
{
100+
this.taskManager.OnProgress += progressReporter.UpdateProgress;
101+
}
102+
catch (Exception ex)
103+
{
104+
LogHelper.Error(ex);
105+
}
106+
92107
}
93108

94109
public void Start()
@@ -170,12 +185,9 @@ private void RefreshCache(CacheType cacheType)
170185
}
171186

172187
public void Refresh(CacheType cacheType)
173-
{
174-
var cache = cacheContainer.GetCache(cacheType);
175-
// if the cache has valid data, we need to force an invalidation to refresh it
176-
// if it doesn't have valid data, it will trigger an invalidation automatically
177-
if (cache.ValidateData())
178-
cache.InvalidateData();
188+
{
189+
var cache = cacheContainer.GetCache(cacheType);
190+
cache.InvalidateData();
179191
}
180192

181193
private void CacheHasBeenInvalidated(CacheType cacheType)
@@ -190,32 +202,32 @@ private void CacheHasBeenInvalidated(CacheType cacheType)
190202
switch (cacheType)
191203
{
192204
case CacheType.Branches:
193-
repositoryManager?.UpdateBranches();
205+
repositoryManager?.UpdateBranches().Start();
194206
break;
195207

196208
case CacheType.GitLog:
197-
repositoryManager?.UpdateGitLog();
209+
repositoryManager?.UpdateGitLog().Start();
198210
break;
199211

200212
case CacheType.GitAheadBehind:
201-
repositoryManager?.UpdateGitAheadBehindStatus();
213+
repositoryManager?.UpdateGitAheadBehindStatus().Start();
202214
break;
203215

204216
case CacheType.GitLocks:
205217
if (CurrentRemote != null)
206-
repositoryManager?.UpdateLocks();
218+
repositoryManager?.UpdateLocks().Start();
207219
break;
208220

209221
case CacheType.GitUser:
210222
// user handles its own invalidation event
211223
break;
212224

213225
case CacheType.RepositoryInfo:
214-
repositoryManager?.UpdateRepositoryInfo();
226+
repositoryManager?.UpdateRepositoryInfo().Start();
215227
break;
216228

217229
case CacheType.GitStatus:
218-
repositoryManager?.UpdateGitStatus();
230+
repositoryManager?.UpdateGitStatus().Start();
219231
break;
220232

221233
default:

0 commit comments

Comments
 (0)