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

Commit 0e0f69e

Browse files
Adding a field to window to determine a branch is tracked remotely
1 parent f91d092 commit 0e0f69e

File tree

1 file changed

+15
-2
lines changed
  • src/UnityExtension/Assets/Editor/GitHub.Unity/UI

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Window : BaseWindow
4040
[SerializeField] private int statusAhead;
4141
[SerializeField] private int statusBehind;
4242
[SerializeField] private bool hasItemsToCommit;
43+
[SerializeField] private bool isTrackingRemoteBranch;
4344
[SerializeField] private GUIContent currentBranchContent;
4445
[SerializeField] private GUIContent currentRemoteUrlContent;
4546
[SerializeField] private CacheUpdateEvent lastCurrentBranchAndRemoteChangedEvent;
@@ -279,7 +280,17 @@ private void MaybeUpdateData()
279280
currentBranchAndRemoteHasUpdate = false;
280281

281282
var repositoryCurrentBranch = Repository.CurrentBranch;
282-
var updatedRepoBranch = repositoryCurrentBranch.HasValue ? repositoryCurrentBranch.Value.Name : null;
283+
string updatedRepoBranch;
284+
if (repositoryCurrentBranch.HasValue)
285+
{
286+
updatedRepoBranch = repositoryCurrentBranch.Value.Name;
287+
isTrackingRemoteBranch = !string.IsNullOrEmpty(repositoryCurrentBranch.Value.Tracking);
288+
}
289+
else
290+
{
291+
updatedRepoBranch = null;
292+
isTrackingRemoteBranch = false;
293+
}
283294

284295
var repositoryCurrentRemote = Repository.CurrentRemote;
285296
if (repositoryCurrentRemote.HasValue)
@@ -313,6 +324,8 @@ private void MaybeUpdateData()
313324
}
314325
else
315326
{
327+
isTrackingRemoteBranch = false;
328+
316329
if (currentRemoteName != null)
317330
{
318331
currentRemoteName = null;
@@ -591,7 +604,7 @@ private void DoActionbarGUI()
591604
EditorGUI.EndDisabledGroup();
592605

593606
// Push button
594-
EditorGUI.BeginDisabledGroup(currentRemoteName == null || statusAhead == 0);
607+
EditorGUI.BeginDisabledGroup(currentRemoteName == null || isTrackingRemoteBranch && statusAhead == 0);
595608
{
596609
var pushButtonText = statusAhead > 0 ? new GUIContent(String.Format(Localization.PushButtonCount, statusAhead)) : pushButtonContent;
597610
var pushClicked = GUILayout.Button(pushButtonText, Styles.ToolbarButtonStyle);

0 commit comments

Comments
 (0)