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

Commit 4ea4aeb

Browse files
Merge branch 'master' into fixes/451-title-icon-loading
2 parents 7b691f4 + 106628d commit 4ea4aeb

File tree

13 files changed

+89
-185
lines changed

13 files changed

+89
-185
lines changed

docs/contributing/how-to-build.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This repository is LFS-enabled. To clone it, you should use a git client that su
66

77
### Windows
88

9-
- Visual Studio 2015+ or Mono 4.x + bash shell (git bash).
9+
- Visual Studio 2015+ or [Mono 4.x](https://download.mono-project.com/archive/4.8.1/windows-installer/) + bash shell (git bash).
1010
- Mono 5.x will not work
1111
- `UnityEngine.dll` and `UnityEditor.dll`.
1212
- If you've installed Unity in the default location of `C:\Program Files\Unity` or `C:\Program Files (x86)\Unity`, the build will be able to reference these DLLs automatically. Otherwise, you'll need to copy these DLLs from `[Unity installation path]\Unity\Editor\Data\Managed` into the `lib` directory in order for the build to work
@@ -48,7 +48,7 @@ To build with Visual Studio 2015+, open the solution file `GitHub.Unity.sln`. Se
4848

4949
### Mono and Bash (windows and mac)
5050

51-
To build with Mono 4.x and Bash execute `build.sh` in a bash shell.
51+
To build with Mono 4.x and Bash, first ensure Mono is added to PATH. Mono installs to `C:\Program Files\Mono\bin\` by default. Then execute `build.sh` in a bash shell.
5252

5353
## Build Output
5454

src/GitHub.Api/Cache/CacheInterfaces.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public interface ILocalConfigBranchDictionary : IDictionary<string, ConfigBranch
6262

6363
}
6464

65-
public interface IRemoteConfigBranchDictionary : IDictionary<string, IDictionary<string, ConfigBranch>>
65+
public interface IRemoteConfigBranchDictionary : IDictionary<string, Dictionary<string, ConfigBranch>>
6666
{
6767

6868
}

src/GitHub.Api/Git/GitClient.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ ITask<string> Unlock(string file, bool force,
8383
ITask<Version> Version(IOutputProcessor<Version> processor = null);
8484

8585
ITask<Version> LfsVersion(IOutputProcessor<Version> processor = null);
86+
87+
ITask<User> SetConfigUserAndEmail(string username, string email);
8688
}
8789

8890
class GitClient : IGitClient
8991
{
92+
private const string UserNameConfigKey = "user.name";
93+
private const string UserEmailConfigKey = "user.email";
9094
private readonly IEnvironment environment;
9195
private readonly IProcessManager processManager;
9296
private readonly ITaskManager taskManager;
@@ -260,23 +264,30 @@ public ITask<User> GetConfigUserAndEmail()
260264
string username = null;
261265
string email = null;
262266

263-
return GetConfig("user.name", GitConfigSource.User)
267+
return GetConfig(UserNameConfigKey, GitConfigSource.User)
264268
.Then((success, value) => {
265269
if (success)
266270
{
267271
username = value;
268272
}
269273
})
270-
.Then(GetConfig("user.email", GitConfigSource.User)
274+
.Then(GetConfig(UserEmailConfigKey, GitConfigSource.User)
271275
.Then((success, value) => {
272276
if (success)
273277
{
274278
email = value;
275279
}
276280
})).Then(success => {
277-
Logger.Trace("{0}:{1} {2}:{3}", "user.name", username, "user.email", email);
278-
return new User { Name= username, Email = email };
279-
});
281+
Logger.Trace("{0}:{1} {2}:{3}", UserNameConfigKey, username, UserEmailConfigKey, email);
282+
return new User { Name = username, Email = email };
283+
});
284+
}
285+
286+
public ITask<User> SetConfigUserAndEmail(string username, string email)
287+
{
288+
return SetConfig(UserNameConfigKey, username, GitConfigSource.User)
289+
.Then(SetConfig(UserEmailConfigKey, email, GitConfigSource.User))
290+
.Then(b => new User { Name = username, Email = email });
280291
}
281292

282293
public ITask<List<GitLock>> ListLocks(bool local, BaseOutputListProcessor<GitLock> processor = null)

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ class RepositoryManager : IRepositoryManager
9696
private readonly IGitClient gitClient;
9797
private readonly IPlatform platform;
9898
private readonly IRepositoryPathConfiguration repositoryPaths;
99-
private readonly ITaskManager taskManager;
10099
private readonly IRepositoryWatcher watcher;
101100

102101
private bool isBusy;
@@ -113,13 +112,12 @@ class RepositoryManager : IRepositoryManager
113112
public event Action<string, string> OnRemoteBranchRemoved;
114113
public event Action OnRepositoryUpdated;
115114

116-
public RepositoryManager(IPlatform platform, ITaskManager taskManager, IGitConfig gitConfig,
115+
public RepositoryManager(IPlatform platform, IGitConfig gitConfig,
117116
IRepositoryWatcher repositoryWatcher, IGitClient gitClient,
118117
IRepositoryPathConfiguration repositoryPaths)
119118
{
120119
this.repositoryPaths = repositoryPaths;
121120
this.platform = platform;
122-
this.taskManager = taskManager;
123121
this.gitClient = gitClient;
124122
this.watcher = repositoryWatcher;
125123
this.config = gitConfig;
@@ -136,7 +134,7 @@ public static RepositoryManager CreateInstance(IPlatform platform, ITaskManager
136134

137135
var repositoryWatcher = new RepositoryWatcher(platform, repositoryPathConfiguration, taskManager.Token);
138136

139-
return new RepositoryManager(platform, taskManager, gitConfig, repositoryWatcher,
137+
return new RepositoryManager(platform, gitConfig, repositoryWatcher,
140138
gitClient, repositoryPathConfiguration);
141139
}
142140

src/GitHub.Api/Helpers/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ static class Constants
99
public const string UsageFile = "usage.json";
1010
public const string GitInstallPathKey = "GitInstallPath";
1111
public const string TraceLoggingKey = "EnableTraceLogging";
12+
public const string Iso8601Format = "o";
1213

1314
public static readonly Version MinimumGitVersion = new Version(2, 11, 0);
1415
public static readonly Version MinimumGitLfsVersion = new Version(2, 3, 4);

src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ private void ReturnGitLogEntry()
329329
Summary = summary,
330330
Description = description,
331331
CommitID = commitId,
332-
TimeString = time.Value.ToString(DateTimeFormatInfo.CurrentInfo),
333-
CommitTimeString = committerTime.Value.ToString(DateTimeFormatInfo.CurrentInfo)
332+
TimeString = time.Value.ToString(Constants.Iso8601Format),
333+
CommitTimeString = committerTime.Value.ToString(Constants.Iso8601Format)
334334
});
335335
}
336336

src/UnityExtension/Assets/Editor/GitHub.Unity/ApplicationCache.cs

Lines changed: 23 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
4-
using Octokit;
55
using UnityEditor;
66
using UnityEngine;
77
using Application = UnityEngine.Application;
@@ -92,7 +92,6 @@ abstract class ManagedCacheBase<T> : ScriptObjectSingleton<T> where T : Scriptab
9292
private static readonly TimeSpan DataTimeout = TimeSpan.MaxValue;
9393

9494
[NonSerialized] private DateTimeOffset? lastUpdatedAtValue;
95-
9695
[NonSerialized] private DateTimeOffset? lastVerifiedAtValue;
9796

9897
public event Action CacheInvalidated;
@@ -148,14 +147,22 @@ public DateTimeOffset LastUpdatedAt
148147
{
149148
if (!lastUpdatedAtValue.HasValue)
150149
{
151-
lastUpdatedAtValue = DateTimeOffset.Parse(LastUpdatedAtString);
150+
DateTimeOffset result;
151+
if (DateTimeOffset.TryParseExact(LastUpdatedAtString, Constants.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
152+
{
153+
lastUpdatedAtValue = result;
154+
}
155+
else
156+
{
157+
lastUpdatedAtValue = DateTimeOffset.MinValue;
158+
}
152159
}
153160

154161
return lastUpdatedAtValue.Value;
155162
}
156163
set
157164
{
158-
LastUpdatedAtString = value.ToString();
165+
LastUpdatedAtString = value.ToString(Constants.Iso8601Format);
159166
lastUpdatedAtValue = null;
160167
}
161168
}
@@ -166,14 +173,22 @@ public DateTimeOffset LastVerifiedAt
166173
{
167174
if (!lastVerifiedAtValue.HasValue)
168175
{
169-
lastVerifiedAtValue = DateTimeOffset.Parse(LastVerifiedAtString);
176+
DateTimeOffset result;
177+
if (DateTimeOffset.TryParseExact(LastVerifiedAtString, Constants.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
178+
{
179+
lastVerifiedAtValue = result;
180+
}
181+
else
182+
{
183+
lastVerifiedAtValue = DateTimeOffset.MinValue;
184+
}
170185
}
171186

172187
return lastVerifiedAtValue.Value;
173188
}
174189
set
175190
{
176-
LastVerifiedAtString = value.ToString();
191+
LastVerifiedAtString = value.ToString(Constants.Iso8601Format);
177192
lastVerifiedAtValue = null;
178193
}
179194
}
@@ -295,106 +310,6 @@ public void OnAfterDeserialize()
295310
Add(remote, branchesDictionary);
296311
}
297312
}
298-
299-
IEnumerator<KeyValuePair<string, IDictionary<string, ConfigBranch>>> IEnumerable<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.GetEnumerator()
300-
{
301-
throw new NotImplementedException();
302-
//return AsDictionary
303-
// .Select(pair => new KeyValuePair<string, IDictionary<string, ConfigBranch>>(pair.Key, pair.Value.AsDictionary))
304-
// .GetEnumerator();
305-
}
306-
307-
void ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.Add(KeyValuePair<string, IDictionary<string, ConfigBranch>> item)
308-
{
309-
throw new NotImplementedException();
310-
//Guard.ArgumentNotNull(item, "item");
311-
//Guard.ArgumentNotNull(item.Value, "item.Value");
312-
//
313-
//var serializableDictionary = item.Value as SerializableDictionary<string, ConfigBranch>;
314-
//if (serializableDictionary == null)
315-
//{
316-
// serializableDictionary = new SerializableDictionary<string, ConfigBranch>(item.Value);
317-
//}
318-
//
319-
//Add(item.Key, serializableDictionary);
320-
}
321-
322-
bool ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.Contains(KeyValuePair<string, IDictionary<string, ConfigBranch>> item)
323-
{
324-
throw new NotImplementedException();
325-
}
326-
327-
void ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.CopyTo(KeyValuePair<string, IDictionary<string, ConfigBranch>>[] array, int arrayIndex)
328-
{
329-
throw new NotImplementedException();
330-
}
331-
332-
bool ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.Remove(KeyValuePair<string, IDictionary<string, ConfigBranch>> item)
333-
{
334-
throw new NotImplementedException();
335-
}
336-
337-
bool ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.IsReadOnly
338-
{
339-
get { throw new NotImplementedException(); }
340-
}
341-
342-
void IDictionary<string, IDictionary<string, ConfigBranch>>.Add(string key, IDictionary<string, ConfigBranch> value)
343-
{
344-
throw new NotImplementedException();
345-
}
346-
347-
bool IDictionary<string, IDictionary<string, ConfigBranch>>.TryGetValue(string key, out IDictionary<string, ConfigBranch> value)
348-
{
349-
value = null;
350-
351-
Dictionary<string, ConfigBranch> branches;
352-
if (TryGetValue(key, out branches))
353-
{
354-
value = branches;
355-
return true;
356-
}
357-
358-
return false;
359-
}
360-
361-
IDictionary<string, ConfigBranch> IDictionary<string, IDictionary<string, ConfigBranch>>.this[string key]
362-
{
363-
get
364-
{
365-
throw new NotImplementedException();
366-
//var dictionary = (IDictionary<string, IDictionary<string, ConfigBranch>>)this;
367-
//IDictionary<string, ConfigBranch> value;
368-
//if (!dictionary.TryGetValue(key, out value))
369-
//{
370-
// throw new KeyNotFoundException();
371-
//}
372-
//
373-
//return value;
374-
}
375-
set
376-
{
377-
throw new NotImplementedException();
378-
//var dictionary = (IDictionary<string, IDictionary<string, ConfigBranch>>)this;
379-
//dictionary.Add(key, value);
380-
}
381-
}
382-
383-
ICollection<string> IDictionary<string, IDictionary<string, ConfigBranch>>.Keys
384-
{
385-
get
386-
{
387-
throw new NotImplementedException();
388-
}
389-
}
390-
391-
ICollection<IDictionary<string, ConfigBranch>> IDictionary<string, IDictionary<string, ConfigBranch>>.Values
392-
{
393-
get
394-
{
395-
return Values.Cast<IDictionary<string,ConfigBranch>>().ToArray();
396-
}
397-
}
398313
}
399314

400315
[Serializable]
@@ -668,7 +583,7 @@ public void AddLocalBranch(string branch)
668583

669584
public void AddRemoteBranch(string remote, string branch)
670585
{
671-
IDictionary<string, ConfigBranch> branchList;
586+
Dictionary<string, ConfigBranch> branchList;
672587
if (RemoteConfigBranches.TryGetValue(remote, out branchList))
673588
{
674589
if (!branchList.ContainsKey(branch))
@@ -691,7 +606,7 @@ public void AddRemoteBranch(string remote, string branch)
691606

692607
public void RemoveRemoteBranch(string remote, string branch)
693608
{
694-
IDictionary<string, ConfigBranch> branchList;
609+
Dictionary<string, ConfigBranch> branchList;
695610
if (RemoteConfigBranches.TryGetValue(remote, out branchList))
696611
{
697612
if (branchList.ContainsKey(branch))

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,9 @@ private void RepositoryOnLocalAndRemoteBranchListChanged(CacheUpdateEvent cacheU
8888
{
8989
if (!lastLocalAndRemoteBranchListChangedEvent.Equals(cacheUpdateEvent))
9090
{
91-
new ActionTask(TaskManager.Token, () =>
92-
{
93-
lastLocalAndRemoteBranchListChangedEvent = cacheUpdateEvent;
94-
localAndRemoteBranchListHasUpdate = true;
95-
Redraw();
96-
})
97-
{ Affinity = TaskAffinity.UI }.Start();
91+
lastLocalAndRemoteBranchListChangedEvent = cacheUpdateEvent;
92+
localAndRemoteBranchListHasUpdate = true;
93+
Redraw();
9894
}
9995
}
10096

@@ -114,16 +110,11 @@ private void MaybeUpdateData()
114110

115111
private void AttachHandlers(IRepository repository)
116112
{
117-
if (repository == null)
118-
return;
119-
120113
repository.LocalAndRemoteBranchListChanged += RepositoryOnLocalAndRemoteBranchListChanged;
121114
}
122115

123116
private void DetachHandlers(IRepository repository)
124117
{
125-
if (repository == null)
126-
return;
127118

128119
repository.LocalAndRemoteBranchListChanged -= RepositoryOnLocalAndRemoteBranchListChanged;
129120
}

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,8 @@ public override void OnEnable()
5151
userSettingsView.OnEnable();
5252
AttachHandlers(Repository);
5353

54-
if (Repository != null)
55-
{
56-
Repository.CheckCurrentRemoteChangedEvent(lastCurrentRemoteChangedEvent);
57-
Repository.CheckLocksChangedEvent(lastLocksChangedEvent);
58-
}
59-
54+
Repository.CheckCurrentRemoteChangedEvent(lastCurrentRemoteChangedEvent);
55+
Repository.CheckLocksChangedEvent(lastLocksChangedEvent);
6056
metricsHasChanged = true;
6157
}
6258

0 commit comments

Comments
 (0)