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

Commit eead5e4

Browse files
Merge branch 'enhancements/history-detail-tree-view' into enhancements/removing-old-tree-code
2 parents d78cf98 + d0ac82e commit eead5e4

File tree

14 files changed

+803
-796
lines changed

14 files changed

+803
-796
lines changed

common/SolutionInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
namespace System
3232
{
3333
internal static class AssemblyVersionInformation {
34-
internal const string Version = "0.25.0";
34+
internal const string Version = "0.26.0";
3535
}
3636
}

src/GitHub.Api/Git/GitLogEntry.cs

Lines changed: 102 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,54 @@ public struct GitLogEntry
1111
private const string Today = "Today";
1212
private const string Yesterday = "Yesterday";
1313

14-
public string CommitID;
15-
public string MergeA;
16-
public string MergeB;
17-
public string AuthorName;
18-
public string AuthorEmail;
19-
public string CommitEmail;
20-
public string CommitName;
21-
public string Summary;
22-
public string Description;
23-
public string TimeString;
24-
public string CommitTimeString;
25-
public List<GitStatusEntry> Changes;
26-
27-
public string ShortID
14+
public static GitLogEntry Default = new GitLogEntry(String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, DateTimeOffset.MinValue, DateTimeOffset.MinValue, new List<GitStatusEntry>(), String.Empty, String.Empty);
15+
16+
public string commitID;
17+
public string mergeA;
18+
public string mergeB;
19+
public string authorName;
20+
public string authorEmail;
21+
public string commitEmail;
22+
public string commitName;
23+
public string summary;
24+
public string description;
25+
public string timeString;
26+
public string commitTimeString;
27+
public List<GitStatusEntry> changes;
28+
29+
public GitLogEntry(string commitID,
30+
string authorName, string authorEmail,
31+
string commitName, string commitEmail,
32+
string summary,
33+
string description,
34+
DateTimeOffset time, DateTimeOffset commitTime,
35+
List<GitStatusEntry> changes,
36+
string mergeA = null, string mergeB = null) : this()
2837
{
29-
get { return CommitID.Length < 7 ? CommitID : CommitID.Substring(0, 7); }
38+
Guard.ArgumentNotNull(commitID, "commitID");
39+
Guard.ArgumentNotNull(authorName, "authorName");
40+
Guard.ArgumentNotNull(authorEmail, "authorEmail");
41+
Guard.ArgumentNotNull(commitEmail, "commitEmail");
42+
Guard.ArgumentNotNull(commitName, "commitName");
43+
Guard.ArgumentNotNull(summary, "summary");
44+
Guard.ArgumentNotNull(description, "description");
45+
Guard.ArgumentNotNull(changes, "changes");
46+
47+
this.commitID = commitID;
48+
this.authorName = authorName;
49+
this.authorEmail = authorEmail;
50+
this.commitEmail = commitEmail;
51+
this.commitName = commitName;
52+
this.summary = summary;
53+
this.description = description;
54+
55+
Time = time;
56+
CommitTime = commitTime;
57+
58+
this.changes = changes;
59+
60+
this.mergeA = mergeA ?? string.Empty;
61+
this.mergeB = mergeB ?? string.Empty;
3062
}
3163

3264
public string PrettyTimeString
@@ -49,37 +81,78 @@ public DateTimeOffset Time
4981
{
5082
if (!timeValue.HasValue)
5183
{
52-
timeValue = DateTimeOffset.Parse(TimeString);
84+
DateTimeOffset result;
85+
if (DateTimeOffset.TryParseExact(TimeString, Constants.Iso8601Format, CultureInfo.InvariantCulture,DateTimeStyles.None, out result))
86+
{
87+
timeValue = result;
88+
}
89+
else
90+
{
91+
Time = DateTimeOffset.MinValue;
92+
}
5393
}
54-
94+
5595
return timeValue.Value;
5696
}
97+
private set
98+
{
99+
timeString = value.ToString(Constants.Iso8601Format);
100+
timeValue = value;
101+
}
57102
}
58103

59104
[NonSerialized] private DateTimeOffset? commitTimeValue;
60-
public DateTimeOffset? CommitTime
105+
public DateTimeOffset CommitTime
61106
{
62107
get
63108
{
64-
if (!timeValue.HasValue && !string.IsNullOrEmpty(CommitTimeString))
109+
if (!commitTimeValue.HasValue)
65110
{
66-
commitTimeValue = DateTimeOffset.Parse(CommitTimeString);
111+
DateTimeOffset result;
112+
if (DateTimeOffset.TryParseExact(CommitTimeString, Constants.Iso8601Format, CultureInfo.InvariantCulture, DateTimeStyles.None, out result))
113+
{
114+
commitTimeValue = result;
115+
}
116+
else
117+
{
118+
CommitTime = DateTimeOffset.MinValue;
119+
}
67120
}
68121

69-
return commitTimeValue;
122+
return commitTimeValue.Value;
123+
}
124+
private set
125+
{
126+
commitTimeString = value.ToString(Constants.Iso8601Format);
127+
commitTimeValue = value;
70128
}
71129
}
72130

73-
public void Clear()
74-
{
75-
CommitID = MergeA = MergeB = AuthorName = AuthorEmail = Summary = Description = "";
131+
public string ShortID => CommitID.Length < 7 ? CommitID : CommitID.Substring(0, 7);
76132

77-
timeValue = DateTimeOffset.MinValue;
78-
TimeString = timeValue.Value.ToString(DateTimeFormatInfo.CurrentInfo);
133+
public string CommitID => commitID;
79134

80-
commitTimeValue = null;
81-
CommitTimeString = null;
82-
}
135+
public string MergeA => mergeA;
136+
137+
public string MergeB => mergeB;
138+
139+
public string AuthorName => authorName;
140+
141+
public string AuthorEmail => authorEmail;
142+
143+
public string CommitEmail => commitEmail;
144+
145+
public string CommitName => commitName;
146+
147+
public string Summary => summary;
148+
149+
public string Description => description;
150+
151+
public string TimeString => timeString;
152+
153+
public string CommitTimeString => commitTimeString;
154+
155+
public List<GitStatusEntry> Changes => changes;
83156

84157
public override string ToString()
85158
{

src/GitHub.Api/OutputProcessors/LogEntryOutputProcessor.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -317,21 +317,16 @@ private void ReturnGitLogEntry()
317317

318318
if (time.HasValue)
319319
{
320-
RaiseOnEntry(new GitLogEntry()
321-
{
322-
AuthorName = authorName,
323-
CommitName = committerName,
324-
MergeA = mergeA,
325-
MergeB = mergeB,
326-
Changes = changes,
327-
AuthorEmail = authorEmail,
328-
CommitEmail = committerEmail,
329-
Summary = summary,
330-
Description = description,
331-
CommitID = commitId,
332-
TimeString = time.Value.ToString(Constants.Iso8601Format),
333-
CommitTimeString = committerTime.Value.ToString(Constants.Iso8601Format)
334-
});
320+
var gitLogEntry = new GitLogEntry(commitId,
321+
authorName, authorEmail,
322+
committerName, committerEmail,
323+
summary,
324+
description,
325+
time.Value, committerTime.Value,
326+
changes,
327+
mergeA, mergeB);
328+
329+
RaiseOnEntry(gitLogEntry);
335330
}
336331

337332
Reset();

src/GitHub.Api/UI/TreeBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void Load(IEnumerable<TData> treeDatas)
3636

3737
var displayRootLevel = DisplayRootNode ? 1 : 0;
3838

39-
var isSelected = selectedNodePath != null && Title == selectedNodePath;
39+
var isSelected = IsSelectable && selectedNodePath != null && Title == selectedNodePath;
4040
AddNode(Title, Title, -1 + displayRootLevel, true, false, false, false, isSelected, null);
4141

4242
var hideChildren = false;
@@ -318,6 +318,7 @@ private void ToggleParentFoldersChecked(int idx, TNode node, bool isChecked)
318318
protected abstract List<TNode> Nodes { get; }
319319
public abstract string Title { get; set; }
320320
public abstract bool DisplayRootNode { get; set; }
321+
public abstract bool IsSelectable { get; set; }
321322
public abstract bool IsCheckable { get; set; }
322323
public abstract string PathSeparator { get; set; }
323324
}

src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Styles
6464
headerDescriptionStyle,
6565
historyToolbarButtonStyle,
6666
historyLockStyle,
67+
historyEntrySummaryStyle,
6768
historyEntryDetailsStyle,
6869
historyEntryDetailsRightStyle,
6970
historyFileTreeBoxStyle,
@@ -396,6 +397,20 @@ public static GUIStyle HistoryLockStyle
396397
return historyLockStyle;
397398
}
398399
}
400+
public static GUIStyle HistoryEntrySummaryStyle
401+
{
402+
get
403+
{
404+
if (historyEntrySummaryStyle == null)
405+
{
406+
historyEntrySummaryStyle = new GUIStyle(Label);
407+
historyEntrySummaryStyle.name = "HistoryEntrySummaryStyle";
408+
409+
historyEntrySummaryStyle.contentOffset = new Vector2(BaseSpacing * 2, 0);
410+
}
411+
return historyEntrySummaryStyle;
412+
}
413+
}
399414

400415
public static GUIStyle HistoryEntryDetailsStyle
401416
{
@@ -412,6 +427,8 @@ public static GUIStyle HistoryEntryDetailsStyle
412427
historyEntryDetailsStyle.onNormal.textColor = Label.onNormal.textColor;
413428
historyEntryDetailsStyle.onFocused.background = Label.onFocused.background;
414429
historyEntryDetailsStyle.onFocused.textColor = Label.onFocused.textColor;
430+
431+
historyEntryDetailsStyle.contentOffset = new Vector2(BaseSpacing * 2, 0);
415432
}
416433
return historyEntryDetailsStyle;
417434
}

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ private void OnButtonBarGUI()
304304

305305
private void OnTreeGUI(Rect rect)
306306
{
307-
var initialRect = rect;
307+
var treeRenderRect = Rect.zero;
308308
if (treeLocals != null && treeRemotes != null)
309309
{
310310
treeLocals.FolderStyle = Styles.Foldout;
@@ -321,7 +321,7 @@ private void OnTreeGUI(Rect rect)
321321

322322
var treeHadFocus = treeLocals.SelectedNode != null;
323323

324-
rect = treeLocals.Render(initialRect, rect, scroll,
324+
treeRenderRect = treeLocals.Render(rect, scroll,
325325
node => { },
326326
node => {
327327
if (node.IsFolder)
@@ -350,10 +350,11 @@ private void OnTreeGUI(Rect rect)
350350

351351
treeHadFocus = treeRemotes.SelectedNode != null;
352352

353-
rect.y += Styles.TreePadding;
353+
treeRenderRect.y += Styles.TreePadding;
354354

355-
rect = treeRemotes.Render(initialRect, rect, scroll,
356-
node => { },
355+
var treeRemoteDisplayRect = new Rect(rect.x, treeRenderRect.y, rect.width, rect.height);
356+
treeRenderRect = treeRemotes.Render(treeRemoteDisplayRect, scroll,
357+
node => { },
357358
node => {
358359
if (node.IsFolder)
359360
return;
@@ -377,7 +378,7 @@ private void OnTreeGUI(Rect rect)
377378
Redraw();
378379
}
379380

380-
GUILayout.Space(rect.y - initialRect.y);
381+
GUILayout.Space(treeRenderRect.y - rect.y);
381382
}
382383

383384
private GenericMenu CreateContextMenuForLocalBranchNode(TreeNode node)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class ChangesTree : Tree<ChangesTreeNode, GitStatusEntryTreeData>
3838
[SerializeField] public string title = string.Empty;
3939
[SerializeField] public string pathSeparator = "/";
4040
[SerializeField] public bool displayRootNode = true;
41+
[SerializeField] public bool isSelectable = true;
4142
[SerializeField] public bool isCheckable = false;
4243
[SerializeField] private List<ChangesTreeNode> nodes = new List<ChangesTreeNode>();
4344
[SerializeField] private ChangesTreeNode selectedNode = null;
@@ -60,6 +61,12 @@ public override bool IsCheckable
6061
set { isCheckable = value; }
6162
}
6263

64+
public override bool IsSelectable
65+
{
66+
get { return isSelectable; }
67+
set { isSelectable = value; }
68+
}
69+
6370
public override string PathSeparator
6471
{
6572
get { return pathSeparator; }

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ class ChangesView : Subview
2525
[SerializeField] private string commitBody = "";
2626
[SerializeField] private string commitMessage = "";
2727
[SerializeField] private string currentBranch = "[unknown]";
28-
[SerializeField] private Vector2 scroll;
29-
[SerializeField] private CacheUpdateEvent lastCurrentBranchChangedEvent;
30-
[SerializeField] private CacheUpdateEvent lastStatusEntriesChangedEvent;
28+
29+
[SerializeField] private Vector2 treeScroll;
3130
[SerializeField] private ChangesTree treeChanges;
31+
3232
[SerializeField] private List<GitStatusEntry> gitStatusEntries;
33+
3334
[SerializeField] private string changedFilesText = NoChangedFilesLabel;
3435

36+
[SerializeField] private CacheUpdateEvent lastCurrentBranchChangedEvent;
37+
[SerializeField] private CacheUpdateEvent lastStatusEntriesChangedEvent;
38+
3539
public override void OnEnable()
3640
{
3741
base.OnEnable();
@@ -81,7 +85,7 @@ public override void OnGUI()
8185
GUILayout.BeginHorizontal();
8286
GUILayout.BeginVertical(Styles.CommitFileAreaStyle);
8387
{
84-
scroll = GUILayout.BeginScrollView(scroll);
88+
treeScroll = GUILayout.BeginScrollView(treeScroll);
8589
{
8690
OnTreeGUI(new Rect(0f, 0f, Position.width, Position.height - rect.height + Styles.CommitAreaPadding));
8791
}
@@ -102,7 +106,6 @@ public override void OnSelectionChange()
102106

103107
private void OnTreeGUI(Rect rect)
104108
{
105-
var initialRect = rect;
106109
if (treeChanges != null)
107110
{
108111
treeChanges.FolderStyle = Styles.Foldout;
@@ -111,18 +114,16 @@ private void OnTreeGUI(Rect rect)
111114
treeChanges.FocusedTreeNodeStyle = Styles.FocusedTreeNode;
112115
treeChanges.FocusedActiveTreeNodeStyle = Styles.FocusedActiveTreeNode;
113116

114-
rect = treeChanges.Render(initialRect, rect, scroll,
117+
var treeRenderRect = treeChanges.Render(rect, treeScroll,
118+
node => { },
115119
node => { },
116-
node => {
117-
},
118-
node => {
119-
});
120+
node => { });
120121

121122
if (treeChanges.RequiresRepaint)
122123
Redraw();
123-
}
124124

125-
GUILayout.Space(rect.y - initialRect.y);
125+
GUILayout.Space(treeRenderRect.y - rect.y);
126+
}
126127
}
127128

128129
private void RepositoryOnStatusEntriesChanged(CacheUpdateEvent cacheUpdateEvent)

0 commit comments

Comments
 (0)