From 89013c704897eaf277166eb337412d3943b69d98 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 27 Jan 2025 22:46:30 +0800 Subject: [PATCH 1/2] fix: Improve in-progress rebase handling --- src/ViewModels/InProgressContexts.cs | 8 ++++++-- src/ViewModels/WorkingCopy.cs | 4 ++-- src/Views/Repository.axaml | 13 ++++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ViewModels/InProgressContexts.cs b/src/ViewModels/InProgressContexts.cs index 6099c2b96..2892b7cca 100644 --- a/src/ViewModels/InProgressContexts.cs +++ b/src/ViewModels/InProgressContexts.cs @@ -107,8 +107,12 @@ public RebaseInProgress(Repository repo) : base(repo.FullPath, "rebase") { _gitDir = repo.GitDir; - var stoppedSHA = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "stopped-sha")).Trim(); - StoppedAt = new Commands.QuerySingleCommit(repo.FullPath, stoppedSHA).Result() ?? new Models.Commit() { SHA = stoppedSHA }; + var stoppedSHAPath = Path.Combine(repo.GitDir, "rebase-merge", "stopped-sha"); + if (File.Exists(stoppedSHAPath)) + { + var stoppedSHA = File.ReadAllText(stoppedSHAPath).Trim(); + StoppedAt = new Commands.QuerySingleCommit(repo.FullPath, stoppedSHA).Result() ?? new Models.Commit() { SHA = stoppedSHA }; + } var ontoSHA = File.ReadAllText(Path.Combine(repo.GitDir, "rebase-merge", "onto")).Trim(); Onto = new Commands.QuerySingleCommit(repo.FullPath, ontoSHA).Result() ?? new Models.Commit() { SHA = ontoSHA }; diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 0a1c9a474..616f244a4 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -218,7 +218,7 @@ public void SetData(List changes) var inProgress = null as InProgressContext; if (File.Exists(Path.Combine(_repo.GitDir, "CHERRY_PICK_HEAD"))) inProgress = new CherryPickInProgress(_repo); - else if (File.Exists(Path.Combine(_repo.GitDir, "REBASE_HEAD")) && Directory.Exists(Path.Combine(_repo.GitDir, "rebase-merge"))) + else if (Directory.Exists(Path.Combine(_repo.GitDir, "rebase-merge")) || Directory.Exists(Path.Combine(_repo.GitDir, "rebase-apply"))) inProgress = new RebaseInProgress(_repo); else if (File.Exists(Path.Combine(_repo.GitDir, "REVERT_HEAD"))) inProgress = new RevertInProgress(_repo); @@ -291,7 +291,7 @@ public void SetData(List changes) var inProgress = null as InProgressContext; if (File.Exists(Path.Combine(_repo.GitDir, "CHERRY_PICK_HEAD"))) inProgress = new CherryPickInProgress(_repo); - else if (File.Exists(Path.Combine(_repo.GitDir, "REBASE_HEAD")) && Directory.Exists(Path.Combine(_repo.GitDir, "rebase-merge"))) + else if (Directory.Exists(Path.Combine(_repo.GitDir, "rebase-merge")) || Directory.Exists(Path.Combine(_repo.GitDir, "rebase-apply"))) inProgress = new RebaseInProgress(_repo); else if (File.Exists(Path.Combine(_repo.GitDir, "REVERT_HEAD"))) inProgress = new RevertInProgress(_repo); diff --git a/src/Views/Repository.axaml b/src/Views/Repository.axaml index a3aa6f25c..74f628c61 100644 --- a/src/Views/Repository.axaml +++ b/src/Views/Repository.axaml @@ -598,11 +598,18 @@ - - + + -