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

Commit ed03a78

Browse files
Preventing the usage of InitProjectView and SettingsView if GitClient is not ready
1 parent d024758 commit ed03a78

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class GitPathView : Subview
3030

3131
[NonSerialized] private bool isBusy;
3232
[NonSerialized] private bool gitExecHasChanged;
33+
[NonSerialized] private bool gitExecutableIsSet;
34+
35+
public override void InitializeView(IView parent)
36+
{
37+
base.InitializeView(parent);
38+
gitExecutableIsSet = Environment.GitExecutablePath != null;
39+
}
3340

3441
public override void OnEnable()
3542
{
@@ -48,7 +55,7 @@ public override void OnGUI()
4855
// Install path
4956
GUILayout.Label(GitInstallTitle, EditorStyles.boldLabel);
5057

51-
EditorGUI.BeginDisabledGroup(IsBusy || Parent.IsBusy);
58+
EditorGUI.BeginDisabledGroup(!gitExecutableIsSet || IsBusy || Parent.IsBusy);
5259
{
5360
// Install path field
5461
GUILayout.BeginHorizontal();

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ class InitProjectView : Subview
1717

1818
[NonSerialized] private bool isBusy;
1919
[NonSerialized] private bool userHasChanges;
20+
[NonSerialized] private bool gitExecutableIsSet;
21+
22+
public override void InitializeView(IView parent)
23+
{
24+
base.InitializeView(parent);
25+
gitExecutableIsSet = Environment.GitExecutablePath != null;
26+
}
2027

2128
public override void OnEnable()
2229
{
@@ -54,7 +61,7 @@ public override void OnGUI()
5461
{
5562
GUILayout.FlexibleSpace();
5663

57-
EditorGUI.BeginDisabledGroup(IsBusy || !isUserDataPresent);
64+
EditorGUI.BeginDisabledGroup(!gitExecutableIsSet || IsBusy || !isUserDataPresent);
5865
{
5966
if (GUILayout.Button(Localization.InitializeRepositoryButtonText, "Button"))
6067
{
@@ -70,7 +77,7 @@ public override void OnGUI()
7077
}
7178
GUILayout.EndHorizontal();
7279

73-
if (hasCompletedInitialCheck && !isUserDataPresent)
80+
if (gitExecutableIsSet && hasCompletedInitialCheck && !isUserDataPresent)
7481
{
7582
EditorGUILayout.Space();
7683
EditorGUILayout.HelpBox(NoUserOrEmailError, MessageType.Error);

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ namespace GitHub.Unity
77
[Serializable]
88
class UserSettingsView : Subview
99
{
10-
private static readonly Vector2 viewSize = new Vector2(325, 125);
11-
private const string WindowTitle = "User Settings";
12-
1310
private const string GitConfigTitle = "Git Configuration";
1411
private const string GitConfigNameLabel = "Name";
1512
private const string GitConfigEmailLabel = "Email";
@@ -24,12 +21,12 @@ class UserSettingsView : Subview
2421

2522
[NonSerialized] private bool isBusy;
2623
[NonSerialized] private bool userHasChanges;
24+
[NonSerialized] private bool gitExecutableIsSet;
2725

2826
public override void InitializeView(IView parent)
2927
{
3028
base.InitializeView(parent);
31-
Title = WindowTitle;
32-
Size = viewSize;
29+
gitExecutableIsSet = Environment.GitExecutablePath != null;
3330
}
3431

3532
public override void OnDataUpdate()
@@ -42,7 +39,7 @@ public override void OnGUI()
4239
{
4340
GUILayout.Label(GitConfigTitle, EditorStyles.boldLabel);
4441

45-
EditorGUI.BeginDisabledGroup(IsBusy || Parent.IsBusy);
42+
EditorGUI.BeginDisabledGroup(!gitExecutableIsSet || IsBusy || Parent.IsBusy);
4643
{
4744
EditorGUI.BeginChangeCheck();
4845
{

0 commit comments

Comments
 (0)