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

Commit 4731a56

Browse files
Merge branch 'master' into enhancements/subview-is-busy
# Conflicts: # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/AuthenticationWindow.cs # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/HistoryView.cs # src/UnityExtension/Assets/Editor/GitHub.Unity/UI/PublishWindow.cs
2 parents 6328b02 + 3b8c39c commit 4731a56

23 files changed

+407
-718
lines changed

src/GitHub.Api/Git/GitConfig.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,11 @@ public IEnumerable<ConfigRemote> GetRemotes()
8686
return groups
8787
.Where(x => x.Key == "remote")
8888
.SelectMany(x => x.Value)
89+
.Where(x => x.Value.TryGetString("url") != null)
8990
.Select(x => new ConfigRemote
9091
{
9192
Name = x.Key,
92-
Url = x.Value.GetString("url")
93+
Url = x.Value.TryGetString("url")
9394
});
9495
}
9596

@@ -98,7 +99,7 @@ public IEnumerable<ConfigRemote> GetRemotes()
9899
return groups
99100
.Where(x => x.Key == "remote")
100101
.SelectMany(x => x.Value)
101-
.Where(x => x.Key == remote)
102+
.Where(x => x.Key == remote && x.Value.TryGetString("url") != null)
102103
.Select(x => new ConfigRemote
103104
{
104105
Name = x.Key,

src/GitHub.Api/Git/IRepository.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ interface IRepository : IEquatable<IRepository>
1010
{
1111
void Initialize(IRepositoryManager repositoryManager);
1212
void Refresh();
13+
ITask CommitAllFiles(string message, string body);
14+
ITask CommitFiles(List<string> files, string message, string body);
1315
ITask SetupRemote(string remoteName, string remoteUrl);
16+
ITask<List<GitLogEntry>> Log();
1417
ITask Pull();
1518
ITask Push();
1619
ITask Fetch();

src/GitHub.Api/Git/Repository.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.Globalization;
55
using System.Linq;
6+
using System.Threading;
67

78
namespace GitHub.Unity
89
{
@@ -78,6 +79,24 @@ public ITask SetupRemote(string remote, string remoteUrl)
7879
}
7980
}
8081

82+
public ITask<List<GitLogEntry>> Log()
83+
{
84+
if (repositoryManager == null)
85+
return new FuncListTask<GitLogEntry>(TaskHelpers.GetCompletedTask(new List<GitLogEntry>()));
86+
87+
return repositoryManager.Log();
88+
}
89+
90+
public ITask CommitAllFiles(string message, string body)
91+
{
92+
return repositoryManager.CommitAllFiles(message, body);
93+
}
94+
95+
public ITask CommitFiles(List<string> files, string message, string body)
96+
{
97+
return repositoryManager.CommitFiles(files, message, body);
98+
}
99+
81100
public ITask Pull()
82101
{
83102
return repositoryManager.Pull(CurrentRemote.Value.Name, CurrentBranch?.Name);

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ interface IRepositoryManager : IDisposable
2828
void Start();
2929
void Stop();
3030
void Refresh();
31+
ITask CommitAllFiles(string message, string body);
3132
ITask CommitFiles(List<string> files, string message, string body);
33+
ITask<List<GitLogEntry>> Log();
3234
ITask Fetch(string remote);
3335
ITask Pull(string remote, string branch);
3436
ITask Push(string remote, string branch);
@@ -191,6 +193,15 @@ public void Refresh()
191193
UpdateGitStatus();
192194
}
193195

196+
public ITask CommitAllFiles(string message, string body)
197+
{
198+
var add = GitClient.AddAll();
199+
add.OnStart += t => IsBusy = true;
200+
return add
201+
.Then(GitClient.Commit(message, body))
202+
.Finally(() => IsBusy = false);
203+
}
204+
194205
public ITask CommitFiles(List<string> files, string message, string body)
195206
{
196207
var add = GitClient.Add(files);
@@ -200,6 +211,13 @@ public ITask CommitFiles(List<string> files, string message, string body)
200211
.Finally(() => IsBusy = false);
201212
}
202213

214+
public ITask<List<GitLogEntry>> Log()
215+
{
216+
var task = GitClient.Log();
217+
HookupHandlers(task);
218+
return task;
219+
}
220+
203221
public ITask Fetch(string remote)
204222
{
205223
var task = GitClient.Fetch(remote);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public GitStatusTask(IGitObjectFactory gitObjectFactory,
1515

1616
public override string ProcessArguments
1717
{
18-
get { return "-c i18n.logoutputencoding=utf8 -c core.quotepath=false status -b -u --ignored --porcelain"; }
18+
get { return "-c i18n.logoutputencoding=utf8 -c core.quotepath=false status -b -u --porcelain"; }
1919
}
2020
public override TaskAffinity Affinity { get { return TaskAffinity.Exclusive; } }
2121
}

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
<Compile Include="Helpers\Constants.cs" />
110110
<Compile Include="Cache\IBranchCache.cs" />
111111
<Compile Include="Helpers\Validation.cs" />
112+
<Compile Include="Helpers\TaskHelpers.cs" />
112113
<Compile Include="Platform\DefaultEnvironment.cs" />
113114
<Compile Include="Extensions\EnvironmentExtensions.cs" />
114115
<Compile Include="Extensions\FileEventExtensions.cs" />

src/GitHub.Api/Helpers/TaskHelpers.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Threading.Tasks;
2+
3+
namespace GitHub.Unity
4+
{
5+
static class TaskHelpers
6+
{
7+
public static Task<T> GetCompletedTask<T>(T result)
8+
{
9+
return TaskEx.FromResult(result);
10+
}
11+
}
12+
}

src/UnityExtension/Assets/Editor/GitHub.Unity/GitHub.Unity.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
<Compile Include="EntryPoint.cs" />
8686
<Compile Include="Misc\Installer.cs" />
8787
<Compile Include="UI\BaseWindow.cs" />
88-
<Compile Include="UI\PublishWindow.cs" />
88+
<Compile Include="UI\PopupWindow.cs" />
8989
<Compile Include="UI\ProjectWindowInterface.cs" />
9090
<Compile Include="Misc\Styles.cs" />
9191
<Compile Include="Misc\Utility.cs" />
@@ -95,12 +95,12 @@
9595
<Compile Include="Tasks\TaskException.cs" />
9696
<Compile Include="Tools\MozRoots.cs" />
9797
<Compile Include="UI\AuthenticationView.cs" />
98-
<Compile Include="UI\AuthenticationWindow.cs" />
9998
<Compile Include="UI\BranchesView.cs" />
10099
<Compile Include="UI\ChangesetTreeView.cs" />
101100
<Compile Include="UI\ChangesView.cs" />
102101
<Compile Include="UI\HistoryView.cs" />
103102
<Compile Include="UI\IView.cs" />
103+
<Compile Include="UI\LoadingView.cs" />
104104
<Compile Include="UI\PublishView.cs" />
105105
<Compile Include="UI\SettingsView.cs" />
106106
<Compile Include="UI\Subview.cs" />

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

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ namespace GitHub.Unity
77
[Serializable]
88
class AuthenticationView : Subview
99
{
10-
const string usernameLabel = "Username";
11-
const string passwordLabel = "Password";
12-
const string twofaLabel = "2FA Code";
13-
const string loginButton = "Sign in";
14-
const string backButton = "Back";
15-
const string authTitle = "Sign in to GitHub";
16-
const string twofaTitle = "Two-Factor Authentication";
17-
const string twofaDescription = "Open the two-factor authentication app on your device to view your 2FA code and verify your identity.";
18-
const string twofaButton = "Verify";
10+
private static readonly Vector2 viewSize = new Vector2(290, 290);
11+
12+
private const string WindowTitle = "Authenticate";
13+
private const string UsernameLabel = "Username";
14+
private const string PasswordLabel = "Password";
15+
private const string TwofaLabel = "2FA Code";
16+
private const string LoginButton = "Sign in";
17+
private const string BackButton = "Back";
18+
private const string AuthTitle = "Sign in to GitHub";
19+
private const string TwofaTitle = "Two-Factor Authentication";
20+
private const string TwofaDescription = "Open the two-factor authentication app on your device to view your 2FA code and verify your identity.";
21+
private const string TwofaButton = "Verify";
1922

2023
[SerializeField] private Vector2 scroll;
2124
[SerializeField] private string username = "";
@@ -59,6 +62,8 @@ public override void InitializeView(IView parent)
5962
{
6063
base.InitializeView(parent);
6164
need2fa = isBusy = false;
65+
Title = WindowTitle;
66+
Size = viewSize;
6267
}
6368

6469
public override void OnEnable()
@@ -91,7 +96,7 @@ public override void OnGUI()
9196
GUILayout.BeginVertical();
9297
{
9398
GUILayout.Space(11);
94-
GUILayout.Label(authTitle, Styles.HeaderRepoLabelStyle);
99+
GUILayout.Label(AuthTitle, Styles.HeaderRepoLabelStyle);
95100
}
96101
GUILayout.EndVertical();
97102
}
@@ -141,14 +146,14 @@ private void OnGUILogin()
141146
GUILayout.Space(3);
142147
GUILayout.BeginHorizontal();
143148
{
144-
username = EditorGUILayout.TextField(usernameLabel, username, Styles.TextFieldStyle);
149+
username = EditorGUILayout.TextField(UsernameLabel ,username, Styles.TextFieldStyle);
145150
}
146151
GUILayout.EndHorizontal();
147152

148153
GUILayout.Space(Styles.BaseSpacing);
149154
GUILayout.BeginHorizontal();
150155
{
151-
password = EditorGUILayout.PasswordField(passwordLabel, password, Styles.TextFieldStyle);
156+
password = EditorGUILayout.PasswordField(PasswordLabel, password, Styles.TextFieldStyle);
152157
}
153158
GUILayout.EndHorizontal();
154159

@@ -158,7 +163,7 @@ private void OnGUILogin()
158163
GUILayout.BeginHorizontal();
159164
{
160165
GUILayout.FlexibleSpace();
161-
if (GUILayout.Button(loginButton) || (!isBusy && enterPressed))
166+
if (GUILayout.Button(LoginButton) || (!isBusy && enterPressed))
162167
{
163168
GUI.FocusControl(null);
164169
isBusy = true;
@@ -174,15 +179,15 @@ private void OnGUI2FA()
174179
{
175180
GUILayout.BeginVertical();
176181
{
177-
GUILayout.Label(twofaTitle, EditorStyles.boldLabel);
178-
GUILayout.Label(twofaDescription, EditorStyles.wordWrappedLabel);
182+
GUILayout.Label(TwofaTitle, EditorStyles.boldLabel);
183+
GUILayout.Label(TwofaDescription, EditorStyles.wordWrappedLabel);
179184

180185
EditorGUI.BeginDisabledGroup(isBusy);
181186
{
182187
GUILayout.Space(Styles.BaseSpacing);
183188
GUILayout.BeginHorizontal();
184189
{
185-
two2fa = EditorGUILayout.TextField(twofaLabel, two2fa, Styles.TextFieldStyle);
190+
two2fa = EditorGUILayout.TextField(TwofaLabel, two2fa, Styles.TextFieldStyle);
186191
}
187192
GUILayout.EndHorizontal();
188193

@@ -193,14 +198,14 @@ private void OnGUI2FA()
193198
GUILayout.BeginHorizontal();
194199
{
195200
GUILayout.FlexibleSpace();
196-
if (GUILayout.Button(backButton))
201+
if (GUILayout.Button(BackButton))
197202
{
198203
GUI.FocusControl(null);
199204
need2fa = false;
200205
Redraw();
201206
}
202207

203-
if (GUILayout.Button(twofaButton) || (!isBusy && enterPressed))
208+
if (GUILayout.Button(TwofaButton) || (!isBusy && enterPressed))
204209
{
205210
GUI.FocusControl(null);
206211
isBusy = true;

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

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)