|
@@ -32,6 +32,8 @@ namespace Terra.Arbitrator.GUI
|
|
|
public SortColumn CurrentSortColumn { get; private set; } = SortColumn.FilePath;
|
|
|
public float PushProgress { get; private set; }
|
|
|
public string PushProgressMessage { get; private set; }
|
|
|
+ public IReadOnlyList<string> RemoteBranchList { get; private set; } = new List<string>();
|
|
|
+ public string CurrentBranchName { get; private set; } = "master";
|
|
|
|
|
|
private readonly Action _requestRepaint;
|
|
|
private readonly Func<string, string, string, string, bool> _displayDialog;
|
|
@@ -72,6 +74,7 @@ namespace Terra.Arbitrator.GUI
|
|
|
UnstageStep()
|
|
|
.Then(CompareStep)
|
|
|
.Then(FetchUpstreamStep)
|
|
|
+ .Then(FetchBranchDataStep)
|
|
|
.Then(FinalizeRefresh)
|
|
|
.Catch(HandleOperationError)
|
|
|
.Finally(FinishOperation);
|
|
@@ -288,6 +291,36 @@ namespace Terra.Arbitrator.GUI
|
|
|
change.IsSelectedForCommit = selected;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void SwitchToBranch(string targetBranch)
|
|
|
+ {
|
|
|
+ if (IsLoading || targetBranch == CurrentBranchName) return;
|
|
|
+
|
|
|
+ if (Changes.Any())
|
|
|
+ {
|
|
|
+ if (!_displayDialog("Discard Local Changes?", $"You have local changes. To switch branches, these changes must be discarded.\n\nDiscard changes and switch to '{targetBranch}'?", "Yes, Discard and Switch", "Cancel"))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ StartOperation($"Discarding changes and switching to {targetBranch}...");
|
|
|
+ GitService.ResetAndSwitchBranch(targetBranch)
|
|
|
+ .Then(successMsg => { InfoMessage = successMsg; Refresh(); })
|
|
|
+ .Catch(ex => { HandleOperationError(ex); FinishOperation(); });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (!_displayDialog("Confirm Branch Switch", $"Are you sure you want to switch to branch '{targetBranch}'?", "Yes, Switch", "Cancel"))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ StartOperation($"Switching to {targetBranch}...");
|
|
|
+ GitService.SwitchBranch(targetBranch)
|
|
|
+ .Then(successMsg => { InfoMessage = successMsg; Refresh(); })
|
|
|
+ .Catch(ex => { HandleOperationError(ex); FinishOperation(); });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// --- Private Methods ---
|
|
|
|
|
@@ -315,9 +348,17 @@ namespace Terra.Arbitrator.GUI
|
|
|
new Promise<int?>((resolve, _) => resolve(0)) : GitService.GetUpstreamAheadBy();
|
|
|
}
|
|
|
|
|
|
- private void FinalizeRefresh(int? pullCount)
|
|
|
+ private IPromise<BranchData> FetchBranchDataStep(int? pullCount)
|
|
|
{
|
|
|
CommitsToPull = pullCount ?? 0;
|
|
|
+ return GitService.GetBranchData();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void FinalizeRefresh(BranchData branchData)
|
|
|
+ {
|
|
|
+ CurrentBranchName = branchData.CurrentBranch;
|
|
|
+ RemoteBranchList = branchData.AllBranches;
|
|
|
+ ApplyGrouping();
|
|
|
}
|
|
|
|
|
|
// --- Shared Helper Methods ---
|