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

Commit bc4947c

Browse files
Starting to figure out the ChangesView
1 parent e36d932 commit bc4947c

File tree

2 files changed

+91
-68
lines changed

2 files changed

+91
-68
lines changed

src/GitHub.Api/Git/GitStatusEntry.cs

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,63 @@ namespace GitHub.Unity
55
[Serializable]
66
public struct GitStatusEntry
77
{
8-
public string Path;
9-
public string FullPath;
10-
public string ProjectPath;
11-
public string OriginalPath;
12-
public GitFileStatus Status;
13-
public bool Staged;
8+
public static GitStatusEntry Default = new GitStatusEntry();
9+
10+
public string path;
11+
public string fullPath;
12+
public string projectPath;
13+
public string originalPath;
14+
public GitFileStatus status;
15+
public bool staged;
1416

1517
public GitStatusEntry(string path, string fullPath, string projectPath,
1618
GitFileStatus status,
1719
string originalPath = null, bool staged = false)
1820
{
19-
Path = path;
20-
Status = status;
21-
FullPath = fullPath;
22-
ProjectPath = projectPath;
23-
OriginalPath = originalPath;
24-
Staged = staged;
21+
Guard.ArgumentNotNullOrWhiteSpace(path, "path");
22+
Guard.ArgumentNotNullOrWhiteSpace(fullPath, "fullPath");
23+
Guard.ArgumentNotNullOrWhiteSpace(projectPath, "projectPath");
24+
25+
this.path = path;
26+
this.status = status;
27+
this.fullPath = fullPath;
28+
this.projectPath = projectPath;
29+
this.originalPath = originalPath;
30+
this.staged = staged;
2531
}
2632

33+
public string Path => path;
34+
35+
public string FullPath => fullPath;
36+
37+
public string ProjectPath => projectPath;
38+
39+
public string OriginalPath => originalPath;
40+
41+
public GitFileStatus Status => status;
42+
43+
public bool Staged => staged;
44+
2745
public override string ToString()
2846
{
29-
return String.Format("Path:'{0}' Status:'{1}' FullPath:'{2}' ProjectPath:'{3}' OriginalPath:'{4}' Staged:'{5}'", Path, Status, FullPath, ProjectPath, OriginalPath, Staged);
47+
return $"Path:'{Path}' Status:'{Status}' FullPath:'{FullPath}' ProjectPath:'{ProjectPath}' OriginalPath:'{OriginalPath}' Staged:'{Staged}'";
48+
}
49+
}
50+
51+
[Serializable]
52+
public struct GitStatusEntryTreeData : ITreeData
53+
{
54+
public static GitStatusEntryTreeData Default = new GitStatusEntryTreeData(GitStatusEntry.Default);
55+
56+
public GitStatusEntry gitStatusEntry;
57+
58+
public GitStatusEntryTreeData(GitStatusEntry gitStatusEntry)
59+
{
60+
this.gitStatusEntry = gitStatusEntry;
3061
}
62+
63+
public string Name => gitStatusEntry.FullPath;
64+
public bool IsActive => false;
65+
public GitStatusEntry GitStatusEntry => gitStatusEntry;
3166
}
3267
}

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

Lines changed: 43 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using UnityEditor;
45
using UnityEngine;
@@ -27,13 +28,6 @@ class ChangesView : Subview
2728
[SerializeField] private Vector2 horizontalScroll;
2829
[SerializeField] private CacheUpdateEvent lastCurrentBranchChangedEvent;
2930
[SerializeField] private CacheUpdateEvent lastStatusChangedEvent;
30-
[SerializeField] private ChangesetTreeView tree = new ChangesetTreeView();
31-
32-
public override void InitializeView(IView parent)
33-
{
34-
base.InitializeView(parent);
35-
tree.InitializeView(this);
36-
}
3731

3832
public override void OnEnable()
3933
{
@@ -64,7 +58,7 @@ public override void OnGUI()
6458
{
6559
GUILayout.BeginHorizontal();
6660
{
67-
EditorGUI.BeginDisabledGroup(tree.Entries.Count == 0);
61+
EditorGUI.BeginDisabledGroup(false);
6862
{
6963
if (GUILayout.Button(SelectAllButton, EditorStyles.miniButtonLeft))
7064
{
@@ -80,23 +74,18 @@ public override void OnGUI()
8074

8175
GUILayout.FlexibleSpace();
8276

83-
GUILayout.Label(
84-
tree.Entries.Count == 0
85-
? NoChangedFilesLabel
86-
: tree.Entries.Count == 1
87-
? OneChangedFileLabel
88-
: String.Format(ChangedFilesLabel, tree.Entries.Count), EditorStyles.miniLabel);
77+
// GUILayout.Label(
78+
// tree.Entries.Count == 0
79+
// ? NoChangedFilesLabel
80+
// : tree.Entries.Count == 1
81+
// ? OneChangedFileLabel
82+
// : String.Format(ChangedFilesLabel, tree.Entries.Count), EditorStyles.miniLabel);
8983
}
9084
GUILayout.EndHorizontal();
9185

9286
horizontalScroll = GUILayout.BeginScrollView(horizontalScroll);
93-
GUILayout.BeginHorizontal();
94-
GUILayout.BeginVertical(Styles.CommitFileAreaStyle);
9587
{
96-
tree.OnGUI();
9788
}
98-
GUILayout.EndVertical();
99-
GUILayout.EndHorizontal();
10089
GUILayout.EndScrollView();
10190

10291
// Do the commit details area
@@ -156,8 +145,6 @@ private void MaybeUpdateData()
156145
if (currentStatusHasUpdate)
157146
{
158147
currentStatusHasUpdate = false;
159-
var gitStatus = Repository.CurrentStatus;
160-
tree.UpdateEntries(gitStatus.Entries.Where(x => x.Status != GitFileStatus.Ignored).ToList());
161148
}
162149
}
163150

@@ -186,7 +173,8 @@ private void OnCommitDetailsAreaGUI()
186173
GUILayout.Space(Styles.CommitAreaPadding);
187174

188175
// Disable committing when already committing or if we don't have all the data needed
189-
EditorGUI.BeginDisabledGroup(isBusy || string.IsNullOrEmpty(commitMessage) || !tree.CommitTargets.Any(t => t.Any));
176+
//EditorGUI.BeginDisabledGroup(isBusy || string.IsNullOrEmpty(commitMessage) || !tree.CommitTargets.Any(t => t.Any));
177+
EditorGUI.BeginDisabledGroup(isBusy || string.IsNullOrEmpty(commitMessage));
190178
{
191179
GUILayout.BeginHorizontal();
192180
{
@@ -212,48 +200,48 @@ private void OnCommitDetailsAreaGUI()
212200

213201
private void SelectAll()
214202
{
215-
for (var index = 0; index < tree.CommitTargets.Count; ++index)
216-
{
217-
tree.CommitTargets[index].All = true;
218-
}
203+
// for (var index = 0; index < tree.CommitTargets.Count; ++index)
204+
// {
205+
// tree.CommitTargets[index].All = true;
206+
// }
219207
}
220208

221209
private void SelectNone()
222210
{
223-
for (var index = 0; index < tree.CommitTargets.Count; ++index)
224-
{
225-
tree.CommitTargets[index].All = false;
226-
}
211+
// for (var index = 0; index < tree.CommitTargets.Count; ++index)
212+
// {
213+
// tree.CommitTargets[index].All = false;
214+
// }
227215
}
228216

229217
private void Commit()
230218
{
231219
// Do not allow new commits before we have received one successful update
232-
isBusy = true;
233-
234-
var files = Enumerable.Range(0, tree.Entries.Count)
235-
.Where(i => tree.CommitTargets[i].All)
236-
.Select(i => tree.Entries[i].Path)
237-
.ToList();
238-
239-
ITask addTask;
240-
241-
if (files.Count == tree.Entries.Count)
242-
{
243-
addTask = Repository.CommitAllFiles(commitMessage, commitBody);
244-
}
245-
else
246-
{
247-
addTask = Repository.CommitFiles(files, commitMessage, commitBody);
248-
}
249-
250-
addTask
251-
.FinallyInUI((b, exception) =>
252-
{
253-
commitMessage = "";
254-
commitBody = "";
255-
isBusy = false;
256-
}).Start();
220+
// isBusy = true;
221+
//
222+
// var files = Enumerable.Range(0, tree.Entries.Count)
223+
// .Where(i => tree.CommitTargets[i].All)
224+
// .Select(i => tree.Entries[i].Path)
225+
// .ToList();
226+
//
227+
// ITask addTask;
228+
//
229+
// if (files.Count == tree.Entries.Count)
230+
// {
231+
// addTask = Repository.CommitAllFiles(commitMessage, commitBody);
232+
// }
233+
// else
234+
// {
235+
// addTask = Repository.CommitFiles(files, commitMessage, commitBody);
236+
// }
237+
//
238+
// addTask
239+
// .FinallyInUI((b, exception) =>
240+
// {
241+
// commitMessage = "";
242+
// commitBody = "";
243+
// isBusy = false;
244+
// }).Start();
257245
}
258246

259247
public override bool IsBusy

0 commit comments

Comments
 (0)