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

Commit 32641cc

Browse files
Merge branch 'fixes/repository-initialize-git-commands' into enhancements/repository-watcher-refactor
2 parents eb55f8f + 8a9554f commit 32641cc

File tree

11 files changed

+86
-165
lines changed

11 files changed

+86
-165
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/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: 57 additions & 127 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;
@@ -19,18 +19,7 @@ public bool FirstRun
1919
{
2020
get
2121
{
22-
if (!firstRunValue.HasValue)
23-
{
24-
firstRunValue = firstRun;
25-
}
26-
27-
if (firstRun)
28-
{
29-
firstRun = false;
30-
FirstRunAt = DateTimeOffset.Now;
31-
Save(true);
32-
}
33-
22+
EnsureFirstRun();
3423
return firstRunValue.Value;
3524
}
3625
}
@@ -39,17 +28,34 @@ public DateTimeOffset FirstRunAt
3928
{
4029
get
4130
{
31+
EnsureFirstRun();
32+
4233
if (!firstRunAtValue.HasValue)
4334
{
44-
firstRunAtValue = DateTimeOffset.Parse(firstRunAtString);
35+
firstRunAtValue = DateTimeOffset.ParseExact(firstRunAtString, Constants.Iso8601Format, CultureInfo.InvariantCulture);
4536
}
4637

4738
return firstRunAtValue.Value;
4839
}
4940
private set
5041
{
51-
firstRunAtString = value.ToString();
52-
firstRunAtValue = null;
42+
firstRunAtString = value.ToString(Constants.Iso8601Format);
43+
firstRunAtValue = value;
44+
}
45+
}
46+
47+
private void EnsureFirstRun()
48+
{
49+
if (!firstRunValue.HasValue)
50+
{
51+
firstRunValue = firstRun;
52+
}
53+
54+
if (firstRun)
55+
{
56+
firstRun = false;
57+
FirstRunAt = DateTimeOffset.Now;
58+
Save(true);
5359
}
5460
}
5561
}
@@ -183,15 +189,23 @@ public DateTimeOffset LastUpdatedAt
183189
{
184190
if (!lastUpdatedAtValue.HasValue)
185191
{
186-
lastUpdatedAtValue = DateTimeOffset.Parse(LastUpdatedAtString);
192+
DateTimeOffset result;
193+
if (DateTimeOffset.TryParseExact(LastUpdatedAtString, Constants.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
194+
{
195+
lastUpdatedAtValue = result;
196+
}
197+
else
198+
{
199+
lastUpdatedAtValue = DateTimeOffset.MinValue;
200+
}
187201
}
188202

189203
return lastUpdatedAtValue.Value;
190204
}
191205
set
192206
{
193-
LastUpdatedAtString = value.ToString();
194-
lastUpdatedAtValue = null;
207+
LastUpdatedAtString = value.ToString(Constants.Iso8601Format);
208+
lastUpdatedAtValue = value;
195209
}
196210
}
197211

@@ -201,15 +215,23 @@ public DateTimeOffset LastVerifiedAt
201215
{
202216
if (!lastVerifiedAtValue.HasValue)
203217
{
204-
lastVerifiedAtValue = DateTimeOffset.Parse(LastVerifiedAtString);
218+
DateTimeOffset result;
219+
if (DateTimeOffset.TryParseExact(LastVerifiedAtString, Constants.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
220+
{
221+
lastVerifiedAtValue = result;
222+
}
223+
else
224+
{
225+
lastVerifiedAtValue = DateTimeOffset.MinValue;
226+
}
205227
}
206228

207229
return lastVerifiedAtValue.Value;
208230
}
209231
set
210232
{
211-
LastVerifiedAtString = value.ToString();
212-
lastVerifiedAtValue = null;
233+
LastVerifiedAtString = value.ToString(Constants.Iso8601Format);
234+
lastVerifiedAtValue = value;
213235
}
214236
}
215237

@@ -219,15 +241,23 @@ public DateTimeOffset InitializedAt
219241
{
220242
if (!initializedAtValue.HasValue)
221243
{
222-
initializedAtValue = DateTimeOffset.Parse(InitializedAtString);
244+
DateTimeOffset result;
245+
if (DateTimeOffset.TryParseExact(InitializedAtString, Constants.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
246+
{
247+
initializedAtValue = result;
248+
}
249+
else
250+
{
251+
initializedAtValue = DateTimeOffset.MinValue;
252+
}
223253
}
224254

225255
return initializedAtValue.Value;
226256
}
227257
set
228258
{
229-
InitializedAtString = value.ToString();
230-
initializedAtValue = null;
259+
InitializedAtString = value.ToString(Constants.Iso8601Format);
260+
initializedAtValue = value;
231261
}
232262
}
233263

@@ -348,106 +378,6 @@ public void OnAfterDeserialize()
348378
Add(remote, branchesDictionary);
349379
}
350380
}
351-
352-
IEnumerator<KeyValuePair<string, IDictionary<string, ConfigBranch>>> IEnumerable<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.GetEnumerator()
353-
{
354-
throw new NotImplementedException();
355-
//return AsDictionary
356-
// .Select(pair => new KeyValuePair<string, IDictionary<string, ConfigBranch>>(pair.Key, pair.Value.AsDictionary))
357-
// .GetEnumerator();
358-
}
359-
360-
void ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.Add(KeyValuePair<string, IDictionary<string, ConfigBranch>> item)
361-
{
362-
throw new NotImplementedException();
363-
//Guard.ArgumentNotNull(item, "item");
364-
//Guard.ArgumentNotNull(item.Value, "item.Value");
365-
//
366-
//var serializableDictionary = item.Value as SerializableDictionary<string, ConfigBranch>;
367-
//if (serializableDictionary == null)
368-
//{
369-
// serializableDictionary = new SerializableDictionary<string, ConfigBranch>(item.Value);
370-
//}
371-
//
372-
//Add(item.Key, serializableDictionary);
373-
}
374-
375-
bool ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.Contains(KeyValuePair<string, IDictionary<string, ConfigBranch>> item)
376-
{
377-
throw new NotImplementedException();
378-
}
379-
380-
void ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.CopyTo(KeyValuePair<string, IDictionary<string, ConfigBranch>>[] array, int arrayIndex)
381-
{
382-
throw new NotImplementedException();
383-
}
384-
385-
bool ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.Remove(KeyValuePair<string, IDictionary<string, ConfigBranch>> item)
386-
{
387-
throw new NotImplementedException();
388-
}
389-
390-
bool ICollection<KeyValuePair<string, IDictionary<string, ConfigBranch>>>.IsReadOnly
391-
{
392-
get { throw new NotImplementedException(); }
393-
}
394-
395-
void IDictionary<string, IDictionary<string, ConfigBranch>>.Add(string key, IDictionary<string, ConfigBranch> value)
396-
{
397-
throw new NotImplementedException();
398-
}
399-
400-
bool IDictionary<string, IDictionary<string, ConfigBranch>>.TryGetValue(string key, out IDictionary<string, ConfigBranch> value)
401-
{
402-
value = null;
403-
404-
Dictionary<string, ConfigBranch> branches;
405-
if (TryGetValue(key, out branches))
406-
{
407-
value = branches;
408-
return true;
409-
}
410-
411-
return false;
412-
}
413-
414-
IDictionary<string, ConfigBranch> IDictionary<string, IDictionary<string, ConfigBranch>>.this[string key]
415-
{
416-
get
417-
{
418-
throw new NotImplementedException();
419-
//var dictionary = (IDictionary<string, IDictionary<string, ConfigBranch>>)this;
420-
//IDictionary<string, ConfigBranch> value;
421-
//if (!dictionary.TryGetValue(key, out value))
422-
//{
423-
// throw new KeyNotFoundException();
424-
//}
425-
//
426-
//return value;
427-
}
428-
set
429-
{
430-
throw new NotImplementedException();
431-
//var dictionary = (IDictionary<string, IDictionary<string, ConfigBranch>>)this;
432-
//dictionary.Add(key, value);
433-
}
434-
}
435-
436-
ICollection<string> IDictionary<string, IDictionary<string, ConfigBranch>>.Keys
437-
{
438-
get
439-
{
440-
throw new NotImplementedException();
441-
}
442-
}
443-
444-
ICollection<IDictionary<string, ConfigBranch>> IDictionary<string, IDictionary<string, ConfigBranch>>.Values
445-
{
446-
get
447-
{
448-
return Values.Cast<IDictionary<string,ConfigBranch>>().ToArray();
449-
}
450-
}
451381
}
452382

453383
[Serializable]
@@ -740,7 +670,7 @@ public void AddLocalBranch(string branch)
740670

741671
public void AddRemoteBranch(string remote, string branch)
742672
{
743-
IDictionary<string, ConfigBranch> branchList;
673+
Dictionary<string, ConfigBranch> branchList;
744674
if (RemoteConfigBranches.TryGetValue(remote, out branchList))
745675
{
746676
if (!branchList.ContainsKey(branch))
@@ -763,7 +693,7 @@ public void AddRemoteBranch(string remote, string branch)
763693

764694
public void RemoveRemoteBranch(string remote, string branch)
765695
{
766-
IDictionary<string, ConfigBranch> branchList;
696+
Dictionary<string, ConfigBranch> branchList;
767697
if (RemoteConfigBranches.TryGetValue(remote, out branchList))
768698
{
769699
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
@@ -87,13 +87,9 @@ private void RepositoryOnLocalAndRemoteBranchListChanged(CacheUpdateEvent cacheU
8787
{
8888
if (!lastLocalAndRemoteBranchListChangedEvent.Equals(cacheUpdateEvent))
8989
{
90-
new ActionTask(TaskManager.Token, () =>
91-
{
92-
lastLocalAndRemoteBranchListChangedEvent = cacheUpdateEvent;
93-
localAndRemoteBranchListHasUpdate = true;
94-
Redraw();
95-
})
96-
{ Affinity = TaskAffinity.UI }.Start();
90+
lastLocalAndRemoteBranchListChangedEvent = cacheUpdateEvent;
91+
localAndRemoteBranchListHasUpdate = true;
92+
Redraw();
9793
}
9894
}
9995

@@ -113,16 +109,11 @@ private void MaybeUpdateData()
113109

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

122115
private void DetachHandlers(IRepository repository)
123116
{
124-
if (repository == null)
125-
return;
126117

127118
repository.LocalAndRemoteBranchListChanged -= RepositoryOnLocalAndRemoteBranchListChanged;
128119
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ public override void OnDisable()
7070
public override void OnDataUpdate()
7171
{
7272
base.OnDataUpdate();
73+
if (titleContent.image == null)
74+
titleContent = new GUIContent(ActiveView.Title, Styles.SmallLogo);
7375
ActiveView.OnDataUpdate();
7476
}
7577

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)