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

Commit 149ea4c

Browse files
Merge branch 'master' into fixes/window-child-view-attach
2 parents f0f57cb + 651a146 commit 149ea4c

File tree

10 files changed

+43
-216
lines changed

10 files changed

+43
-216
lines changed

src/GitHub.Api/Git/GitBranch.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@ interface ITreeData
1111
[Serializable]
1212
public struct GitBranch : ITreeData
1313
{
14-
private string name;
15-
private string tracking;
16-
private bool active;
14+
public static GitBranch Default = new GitBranch();
15+
16+
public string name;
17+
public string tracking;
18+
public bool isActive;
19+
1720
public string Name { get { return name; } }
1821
public string Tracking { get { return tracking; } }
19-
public bool IsActive { get { return active; } }
22+
public bool IsActive { get { return isActive; } }
2023

2124
public GitBranch(string name, string tracking, bool active)
2225
{
2326
Guard.ArgumentNotNullOrWhiteSpace(name, "name");
2427

2528
this.name = name;
2629
this.tracking = tracking;
27-
this.active = active;
30+
this.isActive = active;
2831
}
2932

3033
public override string ToString()

src/GitHub.Api/Git/GitLock.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ namespace GitHub.Unity
55
[Serializable]
66
public struct GitLock
77
{
8-
public static GitLock Default = new GitLock(null, null, null, -1);
8+
public static GitLock Default = new GitLock { ID = -1 };
99

10-
public readonly int ID;
11-
public readonly string Path;
12-
public readonly string FullPath;
13-
public readonly string User;
10+
public int ID;
11+
public string Path;
12+
public string FullPath;
13+
public string User;
1414

1515
public GitLock(string path, string fullPath, string user, int id)
1616
{

src/GitHub.Api/Git/Repository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ private void RepositoryManager_OnRemoteBranchRemoved(string remote, string name)
303303
Dictionary<string, ConfigBranch> branchList;
304304
if (remoteBranches.TryGetValue(remote, out branchList))
305305
{
306-
if (localBranches.ContainsKey(name))
306+
if (branchList.ContainsKey(name))
307307
{
308-
localBranches.Remove(name);
308+
branchList.Remove(name);
309309

310310
Logger.Trace("OnRemoteBranchListChanged");
311311
OnRemoteBranchListChanged?.Invoke();

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

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -123,56 +123,6 @@ public List<GitBranch> RemoteBranches
123123
}
124124
}
125125

126-
[Location("views/branches.yaml", LocationAttribute.Location.LibraryFolder)]
127-
sealed class Favorites : ScriptObjectSingleton<Favorites>
128-
{
129-
[SerializeField] private List<string> favoriteBranches;
130-
public List<string> FavoriteBranches
131-
{
132-
get
133-
{
134-
if (favoriteBranches == null)
135-
FavoriteBranches = new List<string>();
136-
return favoriteBranches;
137-
}
138-
set
139-
{
140-
favoriteBranches = value;
141-
Save(true);
142-
}
143-
}
144-
145-
public void SetFavorite(string branchName)
146-
{
147-
if (FavoriteBranches.Contains(branchName))
148-
return;
149-
FavoriteBranches.Add(branchName);
150-
Save(true);
151-
}
152-
153-
public void UnsetFavorite(string branchName)
154-
{
155-
if (!FavoriteBranches.Contains(branchName))
156-
return;
157-
FavoriteBranches.Remove(branchName);
158-
Save(true);
159-
}
160-
161-
public void ToggleFavorite(string branchName)
162-
{
163-
if (FavoriteBranches.Contains(branchName))
164-
FavoriteBranches.Remove(branchName);
165-
else
166-
FavoriteBranches.Add(branchName);
167-
Save(true);
168-
}
169-
170-
public bool IsFavorite(string branchName)
171-
{
172-
return FavoriteBranches.Contains(branchName);
173-
}
174-
}
175-
176126
[Location("cache/gitlog.yaml", LocationAttribute.Location.LibraryFolder)]
177127
sealed class GitLogCache : ScriptObjectSingleton<GitLogCache>
178128
{

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

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class BranchesView : Subview
2424
private const string WarningCheckoutBranchExistsOK = "Ok";
2525
private const string NewBranchCancelButton = "x";
2626
private const string NewBranchConfirmButton = "Create";
27-
private const string FavoritesSetting = "Favorites";
28-
private const string FavoritesTitle = "Favorites";
2927
private const string CreateBranchTitle = "Create Branch";
3028
private const string LocalTitle = "Local branches";
3129
private const string RemoteTitle = "Remote branches";
@@ -38,11 +36,9 @@ class BranchesView : Subview
3836
private bool showLocalBranches = true;
3937
private bool showRemoteBranches = true;
4038

41-
[NonSerialized] private List<BranchTreeNode> favorites = new List<BranchTreeNode>();
4239
[NonSerialized] private int listID = -1;
4340
[NonSerialized] private BranchTreeNode newNodeSelection;
4441
[NonSerialized] private BranchesMode targetMode;
45-
[NonSerialized] private bool favoritesHasChanged;
4642

4743
[SerializeField] private BranchTreeNode activeBranchNode;
4844
[SerializeField] private BranchTreeNode localRoot;
@@ -51,7 +47,6 @@ class BranchesView : Subview
5147
[SerializeField] private List<Remote> remotes = new List<Remote>();
5248
[SerializeField] private Vector2 scroll;
5349
[SerializeField] private BranchTreeNode selectedNode;
54-
[SerializeField] private List<string> favoritesList = new List<string>();
5550

5651
public override void InitializeView(IView parent)
5752
{
@@ -63,7 +58,6 @@ public override void OnEnable()
6358
{
6459
base.OnEnable();
6560
AttachHandlers(Repository);
66-
favoritesHasChanged = true;
6761
Refresh();
6862
}
6963

@@ -81,11 +75,6 @@ public override void OnDataUpdate()
8175

8276
private void MaybeUpdateData()
8377
{
84-
if (favoritesHasChanged)
85-
{
86-
favoritesList = Manager.LocalSettings.Get(FavoritesSetting, new List<string>());
87-
favoritesHasChanged = false;
88-
}
8978
}
9079

9180
private void AttachHandlers(IRepository repository)
@@ -150,28 +139,6 @@ public void OnEmbeddedGUI()
150139

151140
GUILayout.BeginVertical(Styles.CommitFileAreaStyle);
152141
{
153-
// Favorites list
154-
if (favorites.Count > 0)
155-
{
156-
GUILayout.Label(FavoritesTitle);
157-
GUILayout.BeginHorizontal();
158-
{
159-
GUILayout.BeginVertical();
160-
{
161-
for (var index = 0; index < favorites.Count; ++index)
162-
{
163-
OnTreeNodeGUI(favorites[index]);
164-
}
165-
}
166-
167-
GUILayout.EndVertical();
168-
}
169-
170-
GUILayout.EndHorizontal();
171-
172-
GUILayout.Space(Styles.BranchListSeperation);
173-
}
174-
175142
// Local branches and "create branch" button
176143
showLocalBranches = EditorGUILayout.Foldout(showLocalBranches, LocalTitle);
177144
if (showLocalBranches)
@@ -254,16 +221,6 @@ public void OnEmbeddedGUI()
254221

255222
private int CompareBranches(GitBranch a, GitBranch b)
256223
{
257-
if (IsFavorite(a.Name))
258-
{
259-
return -1;
260-
}
261-
262-
if (IsFavorite(b.Name))
263-
{
264-
return 1;
265-
}
266-
267224
if (a.Name.Equals("master"))
268225
{
269226
return -1;
@@ -277,11 +234,6 @@ private int CompareBranches(GitBranch a, GitBranch b)
277234
return 0;
278235
}
279236

280-
private bool IsFavorite(string branchName)
281-
{
282-
return !String.IsNullOrEmpty(branchName) && favoritesList.Contains(branchName);
283-
}
284-
285237
private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remote)
286238
{
287239
//Clear the selected node
@@ -297,9 +249,6 @@ private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remo
297249
var tracking = new List<KeyValuePair<int, int>>();
298250
var localBranchNodes = new List<BranchTreeNode>();
299251

300-
// Prepare for updated favorites listing
301-
favorites.Clear();
302-
303252
// Just build directly on the local root, keep track of active branch
304253
localRoot = new BranchTreeNode("", NodeType.Folder, false);
305254
for (var index = 0; index < localBranches.Count; ++index)
@@ -327,12 +276,6 @@ private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remo
327276
}
328277
}
329278

330-
// Add to favorites
331-
if (favoritesList.Contains(branch.Name))
332-
{
333-
favorites.Add(node);
334-
}
335-
336279
// Build into tree
337280
BuildTree(localRoot, node);
338281
}
@@ -371,12 +314,6 @@ private void BuildTree(IEnumerable<GitBranch> local, IEnumerable<GitBranch> remo
371314
}
372315
}
373316

374-
// Add to favorites
375-
if (favoritesList.Contains(branch.Name))
376-
{
377-
favorites.Add(node);
378-
}
379-
380317
// Build on the root of the remote, just like with locals
381318
BuildTree(remotes[remoteIndex].Root, node);
382319
}
@@ -409,26 +346,6 @@ private void BuildTree(BranchTreeNode parent, BranchTreeNode child)
409346
BuildTree(folder, child);
410347
}
411348

412-
private void SetFavorite(BranchTreeNode branch, bool favorite)
413-
{
414-
if (string.IsNullOrEmpty(branch.Name))
415-
{
416-
return;
417-
}
418-
419-
if (!favorite)
420-
{
421-
favorites.Remove(branch);
422-
Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
423-
}
424-
else
425-
{
426-
favorites.Remove(branch);
427-
favorites.Add(branch);
428-
Manager.LocalSettings.Set(FavoritesSetting, favorites.Select(x => x.Name).ToList());
429-
}
430-
}
431-
432349
private void OnButtonBarGUI()
433350
{
434351
if (mode == BranchesMode.Default)
@@ -568,7 +485,6 @@ private void OnTreeNodeGUI(BranchTreeNode node)
568485
var style = node.Active ? Styles.BoldLabel : Styles.Label;
569486
var rect = GUILayoutUtility.GetRect(content, style, GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight));
570487
var clickRect = new Rect(0f, rect.y, Position.width, rect.height);
571-
var favoriteRect = new Rect(clickRect.xMax - clickRect.height * 2f, clickRect.y, clickRect.height, clickRect.height);
572488

573489
var selected = selectedNode == node;
574490
var keyboardFocus = GUIUtility.keyboardControl == listID;
@@ -580,25 +496,6 @@ private void OnTreeNodeGUI(BranchTreeNode node)
580496
{
581497
style.Draw(clickRect, GUIContent.none, false, false, true, keyboardFocus);
582498
}
583-
584-
if (node.Type != NodeType.Folder)
585-
{
586-
var favorite = IsFavorite(node.Name);
587-
if (Event.current.type == EventType.Repaint)
588-
{
589-
GUI.DrawTexture(favoriteRect, favorite ? Styles.FavoriteIconOn : Styles.FavoriteIconOff);
590-
}
591-
else if (Event.current.type == EventType.MouseDown && favoriteRect.Contains(Event.current.mousePosition))
592-
{
593-
SetFavorite(node, !favorite);
594-
Event.current.Use();
595-
}
596-
}
597-
}
598-
// Favorite status
599-
else if (Event.current.type == EventType.Repaint && node.Type != NodeType.Folder && IsFavorite(node.Name))
600-
{
601-
GUI.DrawTexture(favoriteRect, Styles.FavoriteIconOn);
602499
}
603500

604501
// The actual icon and label

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#pragma warning disable 649
2-
31
using System;
42
using System.Linq;
53
using UnityEditor;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#pragma warning disable 649
2-
31
using System;
42
using System.Collections.Generic;
53
using System.IO;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#pragma warning disable 649
2-
31
using System;
42
using System.Collections.Generic;
53
using System.Linq;
@@ -42,7 +40,6 @@ class HistoryView : Subview
4240
[NonSerialized] private int selectionIndex;
4341
[NonSerialized] private bool logHasChanged;
4442
[NonSerialized] private bool useScrollTime;
45-
[NonSerialized] private bool isBusy;
4643

4744
[SerializeField] private Vector2 detailsScroll;
4845
[SerializeField] private Vector2 scroll;
@@ -642,7 +639,7 @@ private void DrawTimelineRectAroundIconRect(Rect parentRect, Rect iconRect)
642639

643640
public override bool IsBusy
644641
{
645-
get { return isBusy; }
642+
get { return false; }
646643
}
647644

648645
private float EntryHeight

0 commit comments

Comments
 (0)