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

Commit b14c601

Browse files
Merge branch 'master' into fixes/settings-view-code-cleanup
2 parents e8d1409 + 1a8546e commit b14c601

19 files changed

+244
-204
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface IRepository : IEquatable<IRepository>
1111
void Initialize(IRepositoryManager repositoryManager);
1212
void Refresh();
1313
ITask SetupRemote(string remoteName, string remoteUrl);
14+
ITask<List<GitLogEntry>> Log();
1415
ITask Pull();
1516
ITask Push();
1617
ITask Fetch();

src/GitHub.Api/Git/Repository.cs

Lines changed: 9 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,14 @@ 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+
8190
public ITask Pull()
8291
{
8392
return repositoryManager.Pull(CurrentRemote.Value.Name, CurrentBranch?.Name);

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface IRepositoryManager : IDisposable
2929
void Stop();
3030
void Refresh();
3131
ITask CommitFiles(List<string> files, string message, string body);
32+
ITask<List<GitLogEntry>> Log();
3233
ITask Fetch(string remote);
3334
ITask Pull(string remote, string branch);
3435
ITask Push(string remote, string branch);
@@ -200,6 +201,13 @@ public ITask CommitFiles(List<string> files, string message, string body)
200201
.Finally(() => IsBusy = false);
201202
}
202203

204+
public ITask<List<GitLogEntry>> Log()
205+
{
206+
var task = GitClient.Log();
207+
HookupHandlers(task);
208+
return task;
209+
}
210+
203211
public ITask Fetch(string remote)
204212
{
205213
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
}
@@ -136,14 +141,14 @@ private void OnGUILogin()
136141
GUILayout.Space(3);
137142
GUILayout.BeginHorizontal();
138143
{
139-
username = EditorGUILayout.TextField(usernameLabel, username, Styles.TextFieldStyle);
144+
username = EditorGUILayout.TextField(UsernameLabel ,username, Styles.TextFieldStyle);
140145
}
141146
GUILayout.EndHorizontal();
142147

143148
GUILayout.Space(Styles.BaseSpacing);
144149
GUILayout.BeginHorizontal();
145150
{
146-
password = EditorGUILayout.PasswordField(passwordLabel, password, Styles.TextFieldStyle);
151+
password = EditorGUILayout.PasswordField(PasswordLabel, password, Styles.TextFieldStyle);
147152
}
148153
GUILayout.EndHorizontal();
149154

@@ -153,7 +158,7 @@ private void OnGUILogin()
153158
GUILayout.BeginHorizontal();
154159
{
155160
GUILayout.FlexibleSpace();
156-
if (GUILayout.Button(loginButton) || (!isBusy && enterPressed))
161+
if (GUILayout.Button(LoginButton) || (!isBusy && enterPressed))
157162
{
158163
GUI.FocusControl(null);
159164
isBusy = true;
@@ -169,15 +174,15 @@ private void OnGUI2FA()
169174
{
170175
GUILayout.BeginVertical();
171176
{
172-
GUILayout.Label(twofaTitle, EditorStyles.boldLabel);
173-
GUILayout.Label(twofaDescription, EditorStyles.wordWrappedLabel);
177+
GUILayout.Label(TwofaTitle, EditorStyles.boldLabel);
178+
GUILayout.Label(TwofaDescription, EditorStyles.wordWrappedLabel);
174179

175180
EditorGUI.BeginDisabledGroup(isBusy);
176181
{
177182
GUILayout.Space(Styles.BaseSpacing);
178183
GUILayout.BeginHorizontal();
179184
{
180-
two2fa = EditorGUILayout.TextField(twofaLabel, two2fa, Styles.TextFieldStyle);
185+
two2fa = EditorGUILayout.TextField(TwofaLabel, two2fa, Styles.TextFieldStyle);
181186
}
182187
GUILayout.EndHorizontal();
183188

@@ -188,14 +193,14 @@ private void OnGUI2FA()
188193
GUILayout.BeginHorizontal();
189194
{
190195
GUILayout.FlexibleSpace();
191-
if (GUILayout.Button(backButton))
196+
if (GUILayout.Button(BackButton))
192197
{
193198
GUI.FocusControl(null);
194199
need2fa = false;
195200
Redraw();
196201
}
197202

198-
if (GUILayout.Button(twofaButton) || (!isBusy && enterPressed))
203+
if (GUILayout.Button(TwofaButton) || (!isBusy && enterPressed))
199204
{
200205
GUI.FocusControl(null);
201206
isBusy = true;

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

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

0 commit comments

Comments
 (0)