|
@@ -11,6 +11,7 @@ using System.Linq;
|
|
|
using UnityEngine;
|
|
|
using LibGit2Sharp;
|
|
|
using System.Text;
|
|
|
+using System.Globalization;
|
|
|
using System.ComponentModel;
|
|
|
using System.Threading.Tasks;
|
|
|
using Terra.Arbitrator.Settings;
|
|
@@ -140,7 +141,7 @@ namespace Terra.Arbitrator.Services
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static async void CommitAndPushExecutor(Action<string> resolve, Action<Exception> reject, List<GitChange> changesToCommit, string commitMessage, string username, string email)
|
|
|
+ public static async void CommitAndPushExecutor(Action<string> resolve, Action<Exception> reject, List<GitChange> changesToCommit, string commitMessage, string username, string email, Action<float, string> onProgress)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -178,7 +179,8 @@ namespace Terra.Arbitrator.Services
|
|
|
repo.Commit(commitMessage, author, author);
|
|
|
}
|
|
|
|
|
|
- await GitCommand.RunAsync(new StringBuilder(), new []{ "push" }, 0, 141);
|
|
|
+ var progressReporter = new Progress<string>(line => ParsePushProgress(line, onProgress));
|
|
|
+ await GitCommand.RunAsync(new StringBuilder(), progressReporter, new[] { "push", "--progress" }, 0, 141);
|
|
|
|
|
|
resolve("Successfully committed and pushed changes!");
|
|
|
}
|
|
@@ -188,6 +190,26 @@ namespace Terra.Arbitrator.Services
|
|
|
reject(new Exception(errorMessage));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private static void ParsePushProgress(string line, Action<float, string> onProgress)
|
|
|
+ {
|
|
|
+ if (onProgress == null || string.IsNullOrWhiteSpace(line)) return;
|
|
|
+
|
|
|
+ line = line.Trim();
|
|
|
+ var parts = line.Split(new[] { ':' }, 2);
|
|
|
+ if (parts.Length < 2) return;
|
|
|
+
|
|
|
+ var action = parts[0];
|
|
|
+ var progressPart = parts[1];
|
|
|
+
|
|
|
+ var percentIndex = progressPart.IndexOf('%');
|
|
|
+ if (percentIndex == -1) return;
|
|
|
+
|
|
|
+ var percentString = progressPart.Substring(0, percentIndex).Trim();
|
|
|
+ if (!float.TryParse(percentString, NumberStyles.Any, CultureInfo.InvariantCulture, out var percentage)) return;
|
|
|
+ var progressValue = percentage / 100.0f;
|
|
|
+ onProgress(progressValue, $"{action}...");
|
|
|
+ }
|
|
|
|
|
|
public static void ResetFileExecutor(Action<string> resolve, Action<Exception> reject, GitChange changeToReset)
|
|
|
{
|