enhance: show git errors when failed to get the repository root dir of given path (#397)

This commit is contained in:
leo 2024-08-27 15:35:10 +08:00
parent 963916219f
commit b16d267c9b
No known key found for this signature in database
14 changed files with 40 additions and 39 deletions

View file

@ -10,16 +10,22 @@
<TextBlock FontSize="18"
Classes="bold"
Text="{DynamicResource Text.Init}"/>
<Grid Margin="0,16,8,0" RowDefinitions="28,28" ColumnDefinitions="120,*">
<Grid Margin="0,16,8,0" ColumnDefinitions="100,*">
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="Auto" MinHeight="32"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0"
Text="{DynamicResource Text.Init.Path}"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"/>
Text="{DynamicResource Text.Init.Path}"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"/>
<TextBlock Grid.Row="0" Grid.Column="1"
Text="{Binding TargetPath}"/>
Text="{Binding TargetPath}"/>
<TextBlock Grid.Row="1" Grid.Column="1"
Text="{DynamicResource Text.Init.Tip}"
Foreground="{DynamicResource Brush.FG2}"/>
Foreground="{DynamicResource Brush.FG2}"
Text="{Binding Reason}"
TextWrapping="Wrap"/>
</Grid>
</StackPanel>
</UserControl>

View file

@ -279,14 +279,14 @@ namespace SourceGit.Views
return;
}
var root = new Commands.QueryRepositoryRootPath(path).Result();
if (string.IsNullOrEmpty(root))
var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd();
if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut))
{
ViewModels.Welcome.Instance.InitRepository(path, parent);
ViewModels.Welcome.Instance.InitRepository(path, parent, test.StdErr);
return;
}
var normalizedPath = root.Replace("\\", "/");
var normalizedPath = test.StdOut.Trim().Replace("\\", "/");
var node = ViewModels.Preference.Instance.FindOrAddNodeByRepositoryPath(normalizedPath, parent, true);
ViewModels.Welcome.Instance.Refresh();

View file

@ -55,14 +55,14 @@ namespace SourceGit.Views
return;
}
var root = new Commands.QueryRepositoryRootPath(path).Result();
if (string.IsNullOrEmpty(root))
var test = new Commands.QueryRepositoryRootPath(path).ReadToEnd();
if (!test.IsSuccess || string.IsNullOrEmpty(test.StdOut))
{
ViewModels.Welcome.Instance.InitRepository(path, parent);
ViewModels.Welcome.Instance.InitRepository(path, parent, test.StdErr);
return;
}
var normalizedPath = root.Replace("\\", "/");
var normalizedPath = test.StdOut.Trim().Replace("\\", "/");
var node = ViewModels.Preference.Instance.FindOrAddNodeByRepositoryPath(normalizedPath, parent, false);
ViewModels.Welcome.Instance.Refresh();