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

Commit e04f587

Browse files
Merge pull request #758 from github-for-unity/fixes/gitpath-buttons-state
Enable/disable the git path buttons in the settings view appropriately
2 parents cca0f01 + 292acf1 commit e04f587

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class GitPathView : Subview
1212
private const string PathToGit = "Path to Git";
1313
private const string PathToGitLfs = "Path to Git LFS";
1414
private const string GitPathSaveButton = "Save";
15-
private const string UseInternalGitButton = "Use bundled git";
15+
private const string SetToBundledGitButton = "Set to bundled git";
1616
private const string FindSystemGitButton = "Find system git";
1717
private const string BrowseButton = "...";
1818
private const string GitInstallBrowseTitle = "Select executable";
@@ -96,7 +96,7 @@ public override void OnGUI()
9696
}
9797
if (EditorGUI.EndChangeCheck())
9898
{
99-
changingManually = true;
99+
changingManually = gitPath != installationState.GitExecutablePath || gitLfsPath != installationState.GitLfsExecutablePath;
100100
}
101101
}
102102
GUILayout.EndHorizontal();
@@ -123,7 +123,7 @@ public override void OnGUI()
123123
}
124124
if (EditorGUI.EndChangeCheck())
125125
{
126-
changingManually = true;
126+
changingManually = gitPath != installationState.GitExecutablePath || gitLfsPath != installationState.GitLfsExecutablePath;;
127127
errorMessage = "";
128128
}
129129
}
@@ -147,18 +147,26 @@ public override void OnGUI()
147147
}
148148
EditorGUI.EndDisabledGroup();
149149

150-
if (GUILayout.Button(UseInternalGitButton, GUILayout.ExpandWidth(false)))
150+
// disable the button if the paths are already pointing to the bundled git
151+
// both on windows, only lfs on mac
152+
EditorGUI.BeginDisabledGroup(
153+
(!Environment.IsWindows || gitPath == installDetails.GitExecutablePath) &&
154+
gitLfsPath == installDetails.GitLfsExecutablePath);
151155
{
152-
GUI.FocusControl(null);
156+
if (GUILayout.Button(SetToBundledGitButton, GUILayout.ExpandWidth(false)))
157+
{
158+
GUI.FocusControl(null);
153159

154-
if (Environment.IsWindows)
155-
gitPath = installDetails.GitExecutablePath;
156-
gitLfsPath = installDetails.GitLfsExecutablePath;
157-
resetToBundled = true;
158-
resetToSystem = false;
159-
changingManually = false;
160-
errorMessage = "";
160+
if (Environment.IsWindows)
161+
gitPath = installDetails.GitExecutablePath;
162+
gitLfsPath = installDetails.GitLfsExecutablePath;
163+
resetToBundled = gitPath != installationState.GitExecutablePath || gitLfsPath != installationState.GitLfsExecutablePath;
164+
resetToSystem = false;
165+
changingManually = false;
166+
errorMessage = "";
167+
}
161168
}
169+
EditorGUI.EndDisabledGroup();
162170

163171
//Find button - for attempting to locate a new install
164172
if (GUILayout.Button(FindSystemGitButton, GUILayout.ExpandWidth(false)))
@@ -189,7 +197,7 @@ public override void OnGUI()
189197
}
190198
isBusy = false;
191199
resetToBundled = false;
192-
resetToSystem = true;
200+
resetToSystem = gitPath != installationState.GitExecutablePath || gitLfsPath != installationState.GitLfsExecutablePath;
193201
changingManually = false;
194202
errorMessage = "";
195203
Redraw();

0 commit comments

Comments
 (0)