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

Commit 213df43

Browse files
Merge branch 'master' into fixes/publish-view-disable-until-load
# Conflicts: # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PUblishView.cs
2 parents 0126da0 + c3646dd commit 213df43

File tree

8 files changed

+81
-64
lines changed

8 files changed

+81
-64
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.17.0.0";
34+
internal const string Version = "0.18.0.0";
3535
}
3636
}

src/GitHub.Api/Git/Tasks/GitCommitTask.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ public GitCommitTask(string message, string body,
1616

1717
Name = TaskName;
1818
arguments = "commit ";
19-
arguments += String.Format(" -m \"{0}", message);
19+
arguments += String.Format(" -m \"{0}\"", message);
2020
if (!String.IsNullOrEmpty(body))
21-
arguments += String.Format("{0}{1}", Environment.NewLine, body);
22-
arguments += "\"";
21+
arguments += String.Format(" -m \"{0}\"", body);
2322
}
2423

2524
public override string ProcessArguments { get { return arguments; } }

src/GitHub.Api/NewTaskSystem/ProcessTask.cs

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class ProcessWrapper
5656
private readonly Action onEnd;
5757
private readonly Action<Exception, string> onError;
5858
private readonly CancellationToken token;
59-
private readonly List<string> errors = new List<string>();
6059

6160
public Process Process { get; }
6261
public StreamWriter Input { get; private set; }
@@ -78,39 +77,6 @@ public ProcessWrapper(Process process, IOutputProcessor outputProcessor,
7877

7978
public void Run()
8079
{
81-
if (Process.StartInfo.RedirectStandardOutput)
82-
{
83-
Process.OutputDataReceived += (s, e) =>
84-
{
85-
//Logger.Trace("OutputData \"" + (e.Data == null ? "'null'" : e.Data) + "\"");
86-
87-
string encodedData = null;
88-
if (e.Data != null)
89-
{
90-
encodedData = Encoding.UTF8.GetString(Encoding.Default.GetBytes(e.Data));
91-
}
92-
outputProcessor.LineReceived(encodedData);
93-
};
94-
}
95-
96-
if (Process.StartInfo.RedirectStandardError)
97-
{
98-
Process.ErrorDataReceived += (s, e) =>
99-
{
100-
//if (e.Data != null)
101-
//{
102-
// Logger.Trace("ErrorData \"" + (e.Data == null ? "'null'" : e.Data) + "\"");
103-
//}
104-
105-
string encodedData = null;
106-
if (e.Data != null)
107-
{
108-
encodedData = Encoding.UTF8.GetString(Encoding.Default.GetBytes(e.Data));
109-
errors.Add(encodedData);
110-
}
111-
};
112-
}
113-
11480
try
11581
{
11682
Process.Start();
@@ -133,34 +99,65 @@ public void Run()
13399
return;
134100
}
135101

136-
if (Process.StartInfo.RedirectStandardOutput)
137-
Process.BeginOutputReadLine();
138-
if (Process.StartInfo.RedirectStandardError)
139-
Process.BeginErrorReadLine();
140102
if (Process.StartInfo.RedirectStandardInput)
141103
Input = new StreamWriter(Process.StandardInput.BaseStream, new UTF8Encoding(false));
142104

143-
onStart?.Invoke();
105+
var errors = new List<string>();
144106

107+
onStart?.Invoke();
145108
if (Process.StartInfo.CreateNoWindow)
146109
{
147-
while (!WaitForExit(500))
110+
if (Process.StartInfo.RedirectStandardOutput)
148111
{
149-
if (token.IsCancellationRequested)
112+
var outputStream = Process.StandardOutput;
113+
var line = outputStream.ReadLine();
114+
while (line != null)
150115
{
151-
if (!Process.HasExited)
152-
Process.Kill();
153-
Process.Close();
154-
onEnd?.Invoke();
155-
token.ThrowIfCancellationRequested();
116+
outputProcessor.LineReceived(line);
117+
118+
if (token.IsCancellationRequested)
119+
{
120+
if (!Process.HasExited)
121+
Process.Kill();
122+
123+
Process.Close();
124+
onEnd?.Invoke();
125+
token.ThrowIfCancellationRequested();
126+
}
127+
128+
line = outputStream.ReadLine();
156129
}
130+
outputProcessor.LineReceived(null);
157131
}
158132

159-
if (Process.ExitCode != 0 && errors.Count > 0)
133+
if (Process.StartInfo.RedirectStandardError)
160134
{
161-
onError?.Invoke(null, String.Join(Environment.NewLine, errors.ToArray()));
135+
var errorStream = Process.StandardError;
136+
var errorLine = errorStream.ReadLine();
137+
while (errorLine != null)
138+
{
139+
errors.Add(errorLine);
140+
141+
if (token.IsCancellationRequested)
142+
{
143+
if (!Process.HasExited)
144+
Process.Kill();
145+
146+
Process.Close();
147+
onEnd?.Invoke();
148+
token.ThrowIfCancellationRequested();
149+
}
150+
151+
errorLine = errorStream.ReadLine();
152+
}
153+
154+
if (Process.ExitCode != 0 && errors.Count > 0)
155+
{
156+
onError?.Invoke(null, string.Join(Environment.NewLine, errors.ToArray()));
157+
}
162158
}
163159
}
160+
164161
onEnd?.Invoke();
165162
}
166163

src/GitHub.Api/UI/TreeBuilder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ internal static FileTreeNode BuildTreeRoot(IList<GitStatusEntry> newEntries, Lis
119119
}
120120
}
121121

122-
// TODO: Filter .meta files - consider adding them as children of the asset or folder they're supporting
123122
// TODO: In stead of completely rebuilding the tree structure, figure out a way to migrate open/closed states from the old tree to the new
124123
// Build tree structure
125124

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ private void TreeNode(FileTreeNode node)
118118
var target = node.Target;
119119
var isFolder = node.Children.Any();
120120

121+
var isFolderForMeta = false;
122+
if (node.Children.Count() == 1)
123+
{
124+
isFolderForMeta = node.Children.First().Label.Substring(node.Label.Length).Equals(".meta");
125+
}
126+
121127
GUILayout.BeginHorizontal();
122128
{
123129
if (!Readonly)
@@ -186,7 +192,19 @@ private void TreeNode(FileTreeNode node)
186192

187193
if (Event.current.type == EventType.Repaint)
188194
{
189-
var icon = (Texture) node.Icon ?? (isFolder ? Styles.FolderIcon : Styles.DefaultAssetIcon);
195+
var icon = (Texture) node.Icon;
196+
if (icon == null)
197+
{
198+
if (isFolderForMeta || !isFolder)
199+
{
200+
icon = Styles.DefaultAssetIcon;
201+
}
202+
else
203+
{
204+
icon = Styles.FolderIcon;
205+
}
206+
}
207+
190208
if (icon != null)
191209
{
192210
GUI.DrawTexture(iconRect,

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class HistoryView : Subview
3737
private const int HistoryExtraItemCount = 10;
3838
private const float MaxChangelistHeightRatio = .2f;
3939

40-
[NonSerialized] private string currentRemote = "placeholder";
4140
[NonSerialized] private int historyStartIndex;
4241
[NonSerialized] private int historyStopIndex;
4342
[NonSerialized] private float lastWidth;
@@ -62,6 +61,8 @@ class HistoryView : Subview
6261
[SerializeField] private ChangesetTreeView changesetTree = new ChangesetTreeView();
6362
[SerializeField] private List<GitLogEntry> history = new List<GitLogEntry>();
6463
[SerializeField] private bool isBusy;
64+
[SerializeField] private string currentRemote;
65+
[SerializeField] private bool isPublished;
6566

6667
public override void InitializeView(IView parent)
6768
{
@@ -196,7 +197,6 @@ private void UpdateStatusOnMainThread(GitStatus status)
196197

197198
private void UpdateStatus(GitStatus status)
198199
{
199-
currentRemote = Repository.CurrentRemote.HasValue ? Repository.CurrentRemote.Value.Name : null;
200200
statusAhead = status.Ahead;
201201
statusBehind = status.Behind;
202202
}
@@ -224,6 +224,9 @@ private void OnLogUpdate(List<GitLogEntry> entries)
224224

225225
private void MaybeUpdateData()
226226
{
227+
isPublished = Repository.CurrentRemote.HasValue;
228+
currentRemote = isPublished ? Repository.CurrentRemote.Value.Name : "placeholder";
229+
227230
if (!updated)
228231
return;
229232
updated = false;
@@ -347,8 +350,6 @@ public void OnEmbeddedGUI()
347350

348351
GUILayout.FlexibleSpace();
349352

350-
351-
var isPublished = Repository.CurrentRemote.HasValue;
352353
if (isPublished)
353354
{
354355
GUI.enabled = currentRemote != null;

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ class PublishView : Subview
1212
private const string Title = "Publish this repository to GitHub";
1313
private const string PrivateRepoMessage = "You choose who can see and commit to this repository";
1414
private const string PublicRepoMessage = "Anyone can see this repository. You choose who can commit";
15-
private const string PublishViewCreateButton = "Create";
15+
private const string PublishViewCreateButton = "Publish";
16+
private const string OwnersDefaultText = "Select a user or org";
1617
private const string SelectedOwnerLabel = "Owner";
1718
private const string RepositoryNameLabel = "Repository Name";
1819
private const string DescriptionLabel = "Description";
1920
private const string CreatePrivateRepositoryLabel = "Create as a private repository";
2021

2122
[SerializeField] private string username;
22-
[SerializeField] private string[] owners = { };
23+
[SerializeField] private string[] owners = { OwnersDefaultText };
2324
[SerializeField] private int selectedOwner;
2425
[SerializeField] private string repoName = String.Empty;
2526
[SerializeField] private string repoDescription = "";
@@ -78,7 +79,7 @@ private void PopulateView()
7879
return;
7980
}
8081

81-
owners = new[] { user.Login };
82+
owners = owners.Union(new[] { user.Login }).ToArray();
8283
username = user.Login;
8384

8485
Logger.Trace("GetOrganizations");
@@ -144,7 +145,7 @@ public override void OnGUI()
144145
{
145146
GUILayout.Label(SelectedOwnerLabel);
146147

147-
selectedOwner = EditorGUILayout.Popup(0, owners);
148+
selectedOwner = EditorGUILayout.Popup(selectedOwner, owners);
148149
}
149150
GUILayout.EndVertical();
150151

@@ -240,7 +241,7 @@ public override void OnGUI()
240241

241242
private bool IsFormValid
242243
{
243-
get { return !string.IsNullOrEmpty(repoName); }
244+
get { return !string.IsNullOrEmpty(repoName) && !isBusy && selectedOwner != 0; }
244245
}
245246
}
246247
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@ public override void OnRepositoryChanged(IRepository oldRepository)
124124
public override void Refresh()
125125
{
126126
base.Refresh();
127-
if (Repository != null)
127+
if (Repository != null && Repository.CurrentRemote.HasValue)
128+
{
128129
Repository.ListLocks().Start();
130+
}
129131
}
130132

131133
private void AttachHandlers(IRepository repository)

0 commit comments

Comments
 (0)