diff --git a/src/ScriptRunner/ScriptRunner.GUI/App.axaml b/src/ScriptRunner/ScriptRunner.GUI/App.axaml
index 692465c..0213660 100644
--- a/src/ScriptRunner/ScriptRunner.GUI/App.axaml
+++ b/src/ScriptRunner/ScriptRunner.GUI/App.axaml
@@ -12,4 +12,12 @@
+
+
+
+
+
+
+
+
diff --git a/src/ScriptRunner/ScriptRunner.GUI/BackgroundTasks/ConfigRepositoryUpdater.cs b/src/ScriptRunner/ScriptRunner.GUI/BackgroundTasks/ConfigRepositoryUpdater.cs
index 52ae922..8fe55a4 100644
--- a/src/ScriptRunner/ScriptRunner.GUI/BackgroundTasks/ConfigRepositoryUpdater.cs
+++ b/src/ScriptRunner/ScriptRunner.GUI/BackgroundTasks/ConfigRepositoryUpdater.cs
@@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Text;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
using CliWrap;
using ScriptRunner.GUI.Settings;
@@ -11,7 +12,7 @@ namespace ScriptRunner.GUI.BackgroundTasks;
public interface IRepositoryClient
{
- Task IsOutdated(string repoPath);
+ Task<(bool,string)> IsOutdated(string repoPath);
Task PullRepository(string path);
}
@@ -29,16 +30,40 @@ public CliRepositoryClient(CliCommandExecutor cliCommandExecutor)
_cliCommandExecutor = cliCommandExecutor;
}
- public async Task IsOutdated(string repoPath)
+ public async Task<(bool,string)> IsOutdated(string repoPath)
{
_ = await ExecuteCommand(repoPath, "git", "fetch --prune origin --verbose");
+ if(await GetHeadBranchName(repoPath) is {} mainBranch)
+ {
+ var (_, statusForBranch) = await ExecuteCommand(repoPath, "git", $"log {mainBranch}..origin/{mainBranch} --oneline");
+ var outdated = string.IsNullOrWhiteSpace(statusForBranch) == false;
+ return (outdated, mainBranch);
+ }
+
var (success, result) = await ExecuteCommand(repoPath, "git", "status -uno");
- return success && result.Contains("up to date", StringComparison.InvariantCultureIgnoreCase) == false;
+ var isOutdated = success && result.Contains("up to date", StringComparison.InvariantCultureIgnoreCase) == false;
+ return (isOutdated, "current");
}
+ static async Task GetHeadBranchName(string repoPath)
+ {
+ var (_, originDetectOutput) = await ExecuteCommand(repoPath, "git", "remote show origin");
+
+ // Use regular expression to match the 'HEAD branch' line
+ var match = Regex.Match(originDetectOutput, @"HEAD branch:\s*(\S+)");
+ if (match.Success)
+ {
+ return match.Groups[1].Value; // Return the branch name captured by the group
+ }
+
+ return null;
+ }
+
public async Task PullRepository(string path)
{
- var result = await _cliCommandExecutor.Invoke(new CliCommand("git", "pull --rebase=true origin --prune --verbose", path));
+ _ = await ExecuteCommand(path, "git", "fetch --prune origin --verbose");
+ var mainBranch = await GetHeadBranchName(path) ?? "";
+ var result = await _cliCommandExecutor.Invoke(new CliCommand("git", $"rebase origin/{mainBranch} {mainBranch} --verbose", path));
return result.StandardError.Contains("error", StringComparison.InvariantCultureIgnoreCase) == false;
}
@@ -90,11 +115,15 @@ public async Task> CheckAllRepositories()
continue;
}
- var isOutdated = await repositoryClient.IsOutdated(entry.Path);
+ var (isOutdated, branchName) = await repositoryClient.IsOutdated(entry.Path);
if (isOutdated)
{
- outOfDateRepos.Add(new OutdatedRepositoryModel(entry.Path));
+ outOfDateRepos.Add(new OutdatedRepositoryModel()
+ {
+ Path = entry.Path,
+ BranchName = branchName
+ });
}
}
diff --git a/src/ScriptRunner/ScriptRunner.GUI/BackgroundTasks/OutdatedRepositoryModel.cs b/src/ScriptRunner/ScriptRunner.GUI/BackgroundTasks/OutdatedRepositoryModel.cs
index 40e3d90..59d3999 100644
--- a/src/ScriptRunner/ScriptRunner.GUI/BackgroundTasks/OutdatedRepositoryModel.cs
+++ b/src/ScriptRunner/ScriptRunner.GUI/BackgroundTasks/OutdatedRepositoryModel.cs
@@ -1,11 +1,17 @@
-namespace ScriptRunner.GUI.BackgroundTasks;
+using ReactiveUI;
-public class OutdatedRepositoryModel
+namespace ScriptRunner.GUI.BackgroundTasks;
+
+public class OutdatedRepositoryModel:ReactiveObject
{
public string Path { get; set; }
+ public string BranchName { get; set; }
+
+ private bool _isPulling;
- public OutdatedRepositoryModel(string path)
+ public bool IsPulling
{
- Path = path;
+ get => _isPulling;
+ set => this.RaiseAndSetIfChanged(ref _isPulling, value);
}
}
\ No newline at end of file
diff --git a/src/ScriptRunner/ScriptRunner.GUI/ScriptRunner.GUI.csproj b/src/ScriptRunner/ScriptRunner.GUI/ScriptRunner.GUI.csproj
index f392d2c..286a1c4 100644
--- a/src/ScriptRunner/ScriptRunner.GUI/ScriptRunner.GUI.csproj
+++ b/src/ScriptRunner/ScriptRunner.GUI/ScriptRunner.GUI.csproj
@@ -45,6 +45,7 @@
+
diff --git a/src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs b/src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs
index 68bbba0..0b86efc 100644
--- a/src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs
+++ b/src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs
@@ -573,13 +573,22 @@ public async void PullRepoChanges(object arg)
{
if (arg is OutdatedRepositoryModel record)
{
+ record.IsPulling = true;
var result = false;
- await Task.Run(async () => result = await _configRepositoryUpdater.RefreshRepository(record.Path));
- if (result)
+ try
{
- OutOfDateConfigRepositories.Remove(record);
- RefreshSettings();
+ await Task.Run(async () => result = await _configRepositoryUpdater.RefreshRepository(record.Path));
}
+ finally
+ {
+ if (result)
+ {
+ OutOfDateConfigRepositories.Remove(record);
+ RefreshSettings();
+ }
+ record.IsPulling = false;
+ }
+
}
}
diff --git a/src/ScriptRunner/ScriptRunner.GUI/Views/ActionDetailsSection.axaml b/src/ScriptRunner/ScriptRunner.GUI/Views/ActionDetailsSection.axaml
index eebc5d7..6e78516 100644
--- a/src/ScriptRunner/ScriptRunner.GUI/Views/ActionDetailsSection.axaml
+++ b/src/ScriptRunner/ScriptRunner.GUI/Views/ActionDetailsSection.axaml
@@ -122,11 +122,18 @@
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml b/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml
index 19346b4..b00f869 100644
--- a/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml
+++ b/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml
@@ -40,7 +40,7 @@
BackgroundSource="Digger"
TintColor="Black"
TintOpacity="1"
- MaterialOpacity="0.65" />
+ MaterialOpacity="0.85" />
diff --git a/src/ScriptRunner/ScriptRunner.GUI/Views/NotificationSection.axaml b/src/ScriptRunner/ScriptRunner.GUI/Views/NotificationSection.axaml
index 81e824d..34bdd3d 100644
--- a/src/ScriptRunner/ScriptRunner.GUI/Views/NotificationSection.axaml
+++ b/src/ScriptRunner/ScriptRunner.GUI/Views/NotificationSection.axaml
@@ -6,6 +6,7 @@
xmlns:views="clr-namespace:ScriptRunner.GUI.Views"
xmlns:viewModels="clr-namespace:ScriptRunner.GUI.ViewModels"
xmlns:converters="clr-namespace:ScriptRunner.GUI.Converters"
+ xmlns:avalonia="clr-namespace:LoadingIndicators.Avalonia;assembly=LoadingIndicators.Avalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="viewModels:MainWindowViewModel"
x:Class="ScriptRunner.GUI.Views.NotificationSection">
@@ -30,11 +31,13 @@
-
-
-