|
@@ -123,11 +123,13 @@ namespace Terra.Arbitrator.Services
|
|
|
|
|
|
// --- Promise Executor Implementations ---
|
|
// --- Promise Executor Implementations ---
|
|
|
|
|
|
- public static async void GetUpstreamAheadByExecutor(Action<int?> resolve, Action<Exception> reject)
|
|
|
|
|
|
+ public static async void GetUpstreamAheadByExecutor(Action<int?> resolve, Action<Exception> reject, Action<float, string> onProgress)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- await GitCommand.RunAsync(new StringBuilder(), new[] { "fetch" });
|
|
|
|
|
|
+ var progressReporter = new Progress<string>(line => ParseProgress(line, onProgress));
|
|
|
|
+ await GitCommand.RunAsync(new StringBuilder(), progressReporter, new[] { "fetch", "--progress" });
|
|
|
|
+
|
|
using var repo = new Repository(ProjectRoot);
|
|
using var repo = new Repository(ProjectRoot);
|
|
resolve(repo.Head.TrackingDetails.BehindBy);
|
|
resolve(repo.Head.TrackingDetails.BehindBy);
|
|
}
|
|
}
|
|
@@ -242,7 +244,7 @@ namespace Terra.Arbitrator.Services
|
|
repo.Commit(commitMessage, author, author);
|
|
repo.Commit(commitMessage, author, author);
|
|
}
|
|
}
|
|
|
|
|
|
- var progressReporter = new Progress<string>(line => ParsePushProgress(line, onProgress));
|
|
|
|
|
|
+ var progressReporter = new Progress<string>(line => ParseProgress(line, onProgress));
|
|
await GitCommand.RunAsync(new StringBuilder(), progressReporter, new[] { "push", "--progress" }, 0, 141);
|
|
await GitCommand.RunAsync(new StringBuilder(), progressReporter, new[] { "push", "--progress" }, 0, 141);
|
|
|
|
|
|
resolve("Successfully committed and pushed changes!");
|
|
resolve("Successfully committed and pushed changes!");
|
|
@@ -254,7 +256,7 @@ namespace Terra.Arbitrator.Services
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private static void ParsePushProgress(string line, Action<float, string> onProgress)
|
|
|
|
|
|
+ private static void ParseProgress(string line, Action<float, string> onProgress)
|
|
{
|
|
{
|
|
if (onProgress == null || string.IsNullOrWhiteSpace(line)) return;
|
|
if (onProgress == null || string.IsNullOrWhiteSpace(line)) return;
|
|
|
|
|
|
@@ -268,7 +270,7 @@ namespace Terra.Arbitrator.Services
|
|
var percentIndex = progressPart.IndexOf('%');
|
|
var percentIndex = progressPart.IndexOf('%');
|
|
if (percentIndex == -1) return;
|
|
if (percentIndex == -1) return;
|
|
|
|
|
|
- var percentString = progressPart.Substring(0, percentIndex).Trim();
|
|
|
|
|
|
+ var percentString = progressPart[..percentIndex].Trim();
|
|
if (!float.TryParse(percentString, NumberStyles.Any, CultureInfo.InvariantCulture, out var percentage)) return;
|
|
if (!float.TryParse(percentString, NumberStyles.Any, CultureInfo.InvariantCulture, out var percentage)) return;
|
|
var progressValue = percentage / 100.0f;
|
|
var progressValue = percentage / 100.0f;
|
|
onProgress(progressValue, $"{action}...");
|
|
onProgress(progressValue, $"{action}...");
|