fix: Improve in-progress rebase handling (#933)

* fix: Improve in-progress rebase handling

* fix: Close merge popup even if there are conflicts (#941)
This commit is contained in:
GadflyFang 2025-02-06 10:00:35 +08:00 committed by GitHub
parent c2950ad209
commit a4157e11e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 9 deletions

View file

@ -107,8 +107,12 @@ namespace SourceGit.ViewModels
{
_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 };

View file

@ -61,9 +61,9 @@ namespace SourceGit.ViewModels
return Task.Run(() =>
{
var succ = new Commands.Merge(_repo.FullPath, _sourceName, SelectedMode.Arg, SetProgressDescription).Exec();
new Commands.Merge(_repo.FullPath, _sourceName, SelectedMode.Arg, SetProgressDescription).Exec();
CallUIThread(() => _repo.SetWatcherEnabled(true));
return succ;
return true;
});
}

View file

@ -218,7 +218,7 @@ namespace SourceGit.ViewModels
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 @@ namespace SourceGit.ViewModels
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);

View file

@ -598,11 +598,18 @@
<Grid ColumnDefinitions="*,Auto">
<StackPanel Grid.Column="0" Orientation="Horizontal">
<TextBlock FontWeight="Bold" Foreground="{DynamicResource Brush.ConflictForeground}" Text="{DynamicResource Text.InProgress.Rebase}"/>
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="{DynamicResource Brush.ConflictForeground}" Text="{DynamicResource Text.InProgress.Rebase.StoppedAt}"/>
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="DarkOrange" Text="{Binding StoppedAt.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" ToolTip.Tip="{Binding StoppedAt}"/>
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="{DynamicResource Brush.ConflictForeground}"
Text="{DynamicResource Text.InProgress.Rebase.StoppedAt}"
IsVisible="{Binding StoppedAt, Converter={x:Static ObjectConverters.IsNotNull}}" />
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Foreground="DarkOrange"
Text="{Binding StoppedAt.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
IsVisible="{Binding StoppedAt, Converter={x:Static ObjectConverters.IsNotNull}}"
ToolTip.Tip="{Binding StoppedAt}" />
</StackPanel>
<Button Grid.Column="1" Classes="flat" FontWeight="Regular" BorderThickness="0" Content="{DynamicResource Text.Repository.Skip}" Padding="8,2" Click="OnSkipInProgress"/>
<Button Grid.Column="1" Classes="flat" FontWeight="Regular" BorderThickness="0"
Content="{DynamicResource Text.Repository.Skip}" Padding="8,2" Click="OnSkipInProgress"
IsVisible="{Binding StoppedAt, Converter={x:Static ObjectConverters.IsNotNull}}" />
</Grid>
</DataTemplate>