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

Commit 10560bd

Browse files
Switching to use Repository to send commands
1 parent c922648 commit 10560bd

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

src/GitHub.Api/Git/IRepository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ 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);
1416
ITask Pull();
1517
ITask Push();

src/GitHub.Api/Git/Repository.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ public ITask SetupRemote(string remote, string remoteUrl)
7878
}
7979
}
8080

81+
public ITask CommitAllFiles(string message, string body)
82+
{
83+
return repositoryManager.CommitAllFiles(message, body);
84+
}
85+
86+
public ITask CommitFiles(List<string> files, string message, string body)
87+
{
88+
return repositoryManager.CommitFiles(files, message, body);
89+
}
90+
8191
public ITask Pull()
8292
{
8393
return repositoryManager.Pull(CurrentRemote.Value.Name, CurrentBranch?.Name);

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ 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);
3233
ITask Fetch(string remote);
3334
ITask Pull(string remote, string branch);
@@ -191,6 +192,15 @@ public void Refresh()
191192
UpdateGitStatus();
192193
}
193194

195+
public ITask CommitAllFiles(string message, string body)
196+
{
197+
var add = GitClient.AddAll();
198+
add.OnStart += t => IsBusy = true;
199+
return add
200+
.Then(GitClient.Commit(message, body))
201+
.Finally(() => IsBusy = false);
202+
}
203+
194204
public ITask CommitFiles(List<string> files, string message, string body)
195205
{
196206
var add = GitClient.Add(files);

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,22 +192,20 @@ private void Commit()
192192
var files = Enumerable.Range(0, tree.Entries.Count)
193193
.Where(i => tree.CommitTargets[i].All)
194194
.Select(i => tree.Entries[i].Path)
195-
.ToArray();
195+
.ToList();
196196

197-
ITask<string> addTask;
197+
ITask addTask;
198198

199-
if (files.Length == tree.Entries.Count)
199+
if (files.Count == tree.Entries.Count)
200200
{
201-
addTask = GitClient.AddAll();
201+
addTask = Repository.CommitAllFiles(commitMessage, commitBody);
202202
}
203203
else
204204
{
205-
addTask = GitClient.Add(files);
205+
addTask = Repository.CommitFiles(files, commitMessage, commitBody);
206206
}
207207

208208
addTask
209-
.Then(GitClient.Commit(commitMessage, commitBody))
210-
.Then(GitClient.Status())
211209
.FinallyInUI((b, exception) =>
212210
{
213211
commitMessage = "";

0 commit comments

Comments
 (0)