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

Commit d380ace

Browse files
Merge branch 'master' into features/git-fetch-button
2 parents ed21280 + e659480 commit d380ace

File tree

21 files changed

+268
-179
lines changed

21 files changed

+268
-179
lines changed

src/GitHub.Api/Application/ApplicationManagerBase.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,13 @@ public void Dispose()
234234
public CancellationToken CancellationToken { get { return TaskManager.Token; } }
235235
public ITaskManager TaskManager { get; protected set; }
236236
public IGitClient GitClient { get; protected set; }
237-
238-
239-
protected TaskScheduler UIScheduler { get; private set; }
240-
protected SynchronizationContext SynchronizationContext { get; private set; }
241-
protected IRepositoryManager RepositoryManager { get { return repositoryManager; } }
242-
243237
public ISettings LocalSettings { get; protected set; }
244238
public ISettings SystemSettings { get; protected set; }
245239
public ISettings UserSettings { get; protected set; }
246240
public IUsageTracker UsageTracker { get; protected set; }
241+
242+
protected TaskScheduler UIScheduler { get; private set; }
243+
protected SynchronizationContext SynchronizationContext { get; private set; }
244+
protected IRepositoryManager RepositoryManager { get { return repositoryManager; } }
247245
}
248246
}

src/GitHub.Api/Authentication/Keychain.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,26 @@ public IKeychainAdapter Connect(UriString host)
5252

5353
public async Task<IKeychainAdapter> Load(UriString host)
5454
{
55-
var keychainAdapter = FindOrCreateAdapter(host);
55+
KeychainAdapter keychainAdapter = FindOrCreateAdapter(host);
56+
var cachedConnection = connectionCache[host];
57+
58+
logger.Trace($@"Loading KeychainAdapter Host:""{host}"" Cached Username:""{cachedConnection.Username}""");
5659

57-
logger.Trace("Load KeychainAdapter Host:\"{0}\"", host);
5860
var keychainItem = await credentialManager.Load(host);
5961

6062
if (keychainItem == null)
6163
{
62-
logger.Warning("Cannot load host from credential manager; removing from cache");
64+
logger.Warning("Cannot load host from Credential Manager; removing from cache");
65+
await Clear(host, false);
66+
}
67+
else if (keychainItem.Username != cachedConnection.Username)
68+
{
69+
logger.Warning("Item loaded from credential manager does not match connection cache ; removing from cache");
6370
await Clear(host, false);
6471
}
6572
else
6673
{
67-
logger.Trace("Loading KeychainItem:{0}", keychainItem.ToString());
74+
logger.Trace($@"Loaded from Credential Manager Host:""{keychainItem.Host}"" Username:""{keychainItem.Username}""");
6875
keychainAdapter.Set(keychainItem);
6976
}
7077

@@ -113,7 +120,10 @@ private void ReadCacheFromDisk()
113120
if (connections != null)
114121
{
115122
connectionCache =
116-
connections.Select(item => new Connection { Host = new UriString(item.Host), Username = item.Username })
123+
connections.Select(item => {
124+
logger.Trace("ReadCacheFromDisk Item Host:{0} Username:{1}", item.Host, item.Username);
125+
return new Connection { Host = new UriString(item.Host), Username = item.Username };
126+
})
117127
.ToDictionary(connection => connection.Host);
118128
}
119129
else

src/GitHub.Api/Metrics/UsageTracker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void IncrementLaunchCount()
175175

176176
public static void SetMetricsService(IMetricsService instance)
177177
{
178-
Logger.Trace("SetMetricsService instance:{1}", instance?.ToString() ?? "Null");
178+
Logger.Trace("SetMetricsService instance:{0}", instance?.ToString() ?? "Null");
179179
metricsService = instance;
180180
}
181181

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public ApplicationManager(IMainThreadSynchronizationContext synchronizationConte
2323

2424
protected override void SetupMetrics()
2525
{
26+
2627
new ActionTask(CancellationToken,
2728
() => SetupMetrics(Environment.UnityVersion, ApplicationCache.Instance.FirstRun))
2829
{ Affinity = TaskAffinity.UI }
@@ -33,7 +34,7 @@ protected override void InitializeUI()
3334
{
3435
Logger.Trace("Restarted {0}", Environment.Repository);
3536
ProjectWindowInterface.Initialize(Environment.Repository);
36-
var view = Window.GetView();
37+
var view = Window.GetWindow();
3738
if (view != null)
3839
view.Initialize(this);
3940
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace GitHub.Unity
1111
[InitializeOnLoad]
1212
class EntryPoint : ScriptableObject
1313
{
14-
private static ApplicationManager appManager;
15-
1614
// this may run on the loader thread if it's an appdomain restart
1715
static EntryPoint()
1816
{
@@ -69,6 +67,7 @@ private static bool ServerCertificateValidationCallback(object sender, X509Certi
6967
return true;
7068
}
7169

70+
private static ApplicationManager appManager;
7271
public static IApplicationManager ApplicationManager
7372
{
7473
get

src/UnityExtension/Assets/Editor/GitHub.Unity/GitHub.Unity.v3.ncrunchproject

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<HiddenComponentWarnings>
44
<Value>PostBuildEventDisabled</Value>
55
</HiddenComponentWarnings>
6+
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely>
67
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully>
78
</Settings>
89
</ProjectConfiguration>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ public override void InitializeView(IView parent)
6161
need2fa = busy = false;
6262
}
6363

64-
public override void OnShow()
64+
public override void OnEnable()
6565
{
66-
base.OnShow();
66+
base.OnEnable();
6767
}
6868

69-
public override void OnHide()
69+
public override void OnDisable()
7070
{
71-
base.OnHide();
71+
base.OnDisable();
7272
}
7373

7474
public override void OnGUI()

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

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,45 +27,45 @@ public static IView Open(Action<bool> onClose = null)
2727
return authWindow;
2828
}
2929

30-
public override void OnGUI()
30+
public override void Initialize(IApplicationManager applicationManager)
3131
{
32+
base.Initialize(applicationManager);
3233
if (authView == null)
33-
{
34-
CreateViews();
35-
}
36-
authView.OnGUI();
37-
}
38-
39-
public override void Refresh()
40-
{
41-
authView.Refresh();
34+
authView = new AuthenticationView();
35+
authView.InitializeView(this);
4236
}
4337

4438
public override void OnEnable()
4539
{
40+
base.OnEnable();
41+
4642
// Set window title
4743
titleContent = new GUIContent(Title, Styles.SmallLogo);
44+
authView.OnEnable();
45+
}
4846

49-
Utility.UnregisterReadyCallback(CreateViews);
50-
Utility.RegisterReadyCallback(CreateViews);
51-
52-
Utility.UnregisterReadyCallback(ShowActiveView);
53-
Utility.RegisterReadyCallback(ShowActiveView);
47+
public override void OnDisable()
48+
{
49+
base.OnDisable();
50+
authView.OnDisable();
5451
}
5552

56-
private void CreateViews()
53+
public override void OnUI()
5754
{
58-
if (authView == null)
59-
authView = new AuthenticationView();
55+
base.OnUI();
56+
authView.OnGUI();
57+
}
6058

61-
Initialize(EntryPoint.ApplicationManager);
62-
authView.InitializeView(this);
59+
public override void Refresh()
60+
{
61+
base.Refresh();
62+
authView.Refresh();
6363
}
6464

65-
private void ShowActiveView()
65+
public override void OnSelectionChange()
6666
{
67-
authView.OnShow();
68-
Refresh();
67+
base.OnSelectionChange();
68+
authView.OnSelectionChange();
6969
}
7070

7171
public override void Finish(bool result)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public override void InitializeView(IView parent)
4444
targetMode = mode;
4545
}
4646

47-
public override void OnShow()
47+
public override void OnEnable()
4848
{
49-
base.OnShow();
49+
base.OnEnable();
5050
if (Repository != null)
5151
{
5252
Repository.OnLocalBranchListChanged += RunRefreshEmbeddedOnMainThread;
@@ -55,9 +55,9 @@ public override void OnShow()
5555
}
5656
}
5757

58-
public override void OnHide()
58+
public override void OnDisable()
5959
{
60-
base.OnHide();
60+
base.OnDisable();
6161
if (Repository != null)
6262
{
6363
Repository.OnLocalBranchListChanged -= RunRefreshEmbeddedOnMainThread;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public override void InitializeView(IView parent)
3333
tree.InitializeView(this);
3434
}
3535

36-
public override void OnShow()
36+
public override void OnEnable()
3737
{
38-
base.OnShow();
38+
base.OnEnable();
3939
if (Repository == null)
4040
return;
4141

@@ -44,9 +44,9 @@ public override void OnShow()
4444
Repository.Refresh();
4545
}
4646

47-
public override void OnHide()
47+
public override void OnDisable()
4848
{
49-
base.OnHide();
49+
base.OnDisable();
5050
if (Repository == null)
5151
return;
5252
Repository.OnRepositoryChanged -= RunStatusUpdateOnMainThread;

0 commit comments

Comments
 (0)