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

Commit 673e03e

Browse files
Merge branch 'master' into fixes/git-path-file-browser
2 parents 66dc5d8 + 3b8c39c commit 673e03e

21 files changed

+403
-705
lines changed

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/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.

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

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@ namespace GitHub.Unity
66
{
77
abstract class BaseWindow : EditorWindow, IView
88
{
9-
[NonSerialized] private bool finishCalled = false;
109
[NonSerialized] private bool initialized = false;
11-
1210
[NonSerialized] private IApplicationManager cachedManager;
1311
[NonSerialized] private IRepository cachedRepository;
1412
[NonSerialized] private bool initializeWasCalled;
1513
[NonSerialized] private bool inLayout;
1614

17-
public event Action<bool> OnClose;
18-
1915
public virtual void Initialize(IApplicationManager applicationManager)
2016
{
2117
Logger.Trace("Initialize ApplicationManager:{0} Initialized:{1}", applicationManager, initialized);
@@ -49,15 +45,7 @@ public virtual void Refresh()
4945
}
5046

5147
public virtual void Finish(bool result)
52-
{
53-
finishCalled = true;
54-
RaiseOnClose(result);
55-
}
56-
57-
protected void RaiseOnClose(bool result)
58-
{
59-
OnClose.SafeInvoke(result);
60-
}
48+
{}
6149

6250
public virtual void Awake()
6351
{
@@ -73,9 +61,11 @@ public virtual void OnEnable()
7361
InitializeWindow(EntryPoint.ApplicationManager);
7462
}
7563

76-
public virtual void OnDisable() {}
64+
public virtual void OnDisable()
65+
{}
7766

78-
public virtual void Update() {}
67+
public virtual void Update()
68+
{}
7969

8070
public virtual void OnDataUpdate()
8171
{}
@@ -114,17 +104,12 @@ private void OnGUI()
114104
}
115105

116106
public virtual void OnDestroy()
117-
{
118-
if (!finishCalled)
119-
{
120-
RaiseOnClose(false);
121-
}
122-
}
107+
{}
123108

124109
public virtual void OnSelectionChange()
125110
{}
126111

127-
public virtual Rect Position { get { return position; } }
112+
public Rect Position { get { return position; } }
128113
public IApplicationManager Manager { get; private set; }
129114
public IRepository Repository { get { return inLayout ? cachedRepository : Environment.Repository; } }
130115
public bool HasRepository { get { return Environment.RepositoryPath != null; } }

0 commit comments

Comments
 (0)