Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/Commands/QueryCommitChildren.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace SourceGit.Commands
{
public class QueryCommitChildren : Command
{
public QueryCommitChildren(string repo, string sha)
{
WorkingDirectory = repo;
Context = repo;
_sha = sha;
Args = $"rev-list --children --all {sha}^..";
}

public string[] Result()
{
var rs = ReadToEnd();
if (!rs.IsSuccess)
return [];

int start = rs.StdOut.IndexOf($"\n{_sha}");
if (start != -1)
{
int end = rs.StdOut.IndexOf('\n', start + 1);
if (end == -1)
end = rs.StdOut.Length;
start = rs.StdOut.IndexOf(' ', start);
if (start != -1 && start < end)
return rs.StdOut.Substring(start + 1, end - start - 1).Split(' ', System.StringSplitOptions.RemoveEmptyEntries);
}
return [];
}

private string _sha;
}
}
1 change: 1 addition & 0 deletions src/Resources/Locales/en_US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<x:String x:Key="Text.CommitDetail.Info" xml:space="preserve">INFORMATION</x:String>
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">AUTHOR</x:String>
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">CHANGED</x:String>
<x:String x:Key="Text.CommitDetail.Info.Children" xml:space="preserve">CHILDREN</x:String>
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">COMMITTER</x:String>
<x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">Check refs that contains this commit</x:String>
<x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">COMMIT IS CONTAINED BY</x:String>
Expand Down
1 change: 1 addition & 0 deletions src/Resources/Locales/fr_FR.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<x:String x:Key="Text.CommitDetail.Info" xml:space="preserve">INFORMATIONS</x:String>
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">AUTEUR</x:String>
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">CHANGÉ</x:String>
<x:String x:Key="Text.CommitDetail.Info.Children" xml:space="preserve">ENFANTS</x:String>
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">COMMITTER</x:String>
<x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">Vérifier les références contenant ce commit</x:String>
<x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">LE COMMIT EST CONTENU PAR</x:String>
Expand Down
13 changes: 13 additions & 0 deletions src/ViewModels/CommitDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public List<Models.Change> SelectedChanges
}
}

public AvaloniaList<string> Children
{
get;
private set;
} = new AvaloniaList<string>();

public string SearchChangeFilter
{
get => _searchChangeFilter;
Expand Down Expand Up @@ -486,6 +492,7 @@ private void Refresh()
VisibleChanges = null;
SelectedChanges = null;
ViewRevisionFileContent = null;
Children.Clear();

if (_commit == null)
return;
Expand All @@ -502,6 +509,12 @@ private void Refresh()
Dispatcher.UIThread.Invoke(() => SignInfo = signInfo);
});

Task.Run(() =>
{
var children = new Commands.QueryCommitChildren(_repo.FullPath, _commit.SHA).Result();
Dispatcher.UIThread.Invoke(() => Children.AddRange(children));
});

if (_cancelToken != null)
_cancelToken.Requested = true;

Expand Down
34 changes: 28 additions & 6 deletions src/Views/CommitBaseInfo.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<Rectangle Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/>

<!-- Base Information -->
<Grid RowDefinitions="24,Auto,Auto,Auto" ColumnDefinitions="96,*">
<Grid RowDefinitions="24,Auto,Auto,Auto,Auto" ColumnDefinitions="96,*">
<!-- SHA -->
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
Expand Down Expand Up @@ -117,14 +117,36 @@
TextDecorations="Underline"
Cursor="Hand"
Margin="0,0,16,0"
PointerPressed="OnParentSHAPressed"/>
PointerPressed="OnSHAPressed"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

<!-- CHILDREN -->
<TextBlock Grid.Row="2" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Children}"/>
<ItemsControl Grid.Row="2" Grid.Column="1" Height="24" Margin="12,0,0,0" ItemsSource="{Binding #ThisControl.Children}" IsVisible="{Binding #ThisControl.Children.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Classes="primary"
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
Foreground="DarkOrange"
TextDecorations="Underline"
Cursor="Hand"
Margin="0,0,16,0"
PointerPressed="OnSHAPressed"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

<!-- REFS -->
<TextBlock Grid.Row="2" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Refs}" IsVisible="{Binding HasDecorators}"/>
<Border Grid.Row="2" Grid.Column="1" Margin="12,0,0,0" Height="24" IsVisible="{Binding HasDecorators}">
<TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Refs}" IsVisible="{Binding HasDecorators}"/>
<Border Grid.Row="3" Grid.Column="1" Margin="12,0,0,0" Height="24" IsVisible="{Binding HasDecorators}">
<v:CommitRefsPresenter TagBackground="{DynamicResource Brush.DecoratorTag}"
Foreground="{DynamicResource Brush.FG1}"
FontFamily="{DynamicResource Fonts.Primary}"
Expand All @@ -134,8 +156,8 @@
</Border>

<!-- Messages -->
<TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Message}" VerticalAlignment="Top" Margin="0,4,0,0" />
<v:CommitMessagePresenter Grid.Row="3" Grid.Column="1"
<TextBlock Grid.Row="4" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Message}" VerticalAlignment="Top" Margin="0,4,0,0" />
<v:CommitMessagePresenter Grid.Row="4" Grid.Column="1"
Margin="12,5,8,0"
Classes="primary"
Message="{Binding #ThisControl.Message}"
Expand Down
11 changes: 10 additions & 1 deletion src/Views/CommitBaseInfo.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public AvaloniaList<Models.IssueTrackerRule> IssueTrackerRules
set => SetValue(IssueTrackerRulesProperty, value);
}

public static readonly StyledProperty<AvaloniaList<string>> ChildrenProperty =
AvaloniaProperty.Register<CommitBaseInfo, AvaloniaList<string>>(nameof(Children));

public AvaloniaList<string> Children
{
get => GetValue(ChildrenProperty);
set => SetValue(ChildrenProperty, value);
}

public CommitBaseInfo()
{
InitializeComponent();
Expand Down Expand Up @@ -113,7 +122,7 @@ private void OnOpenContainsIn(object sender, RoutedEventArgs e)
e.Handled = true;
}

private void OnParentSHAPressed(object sender, PointerPressedEventArgs e)
private void OnSHAPressed(object sender, PointerPressedEventArgs e)
{
if (DataContext is ViewModels.CommitDetail detail && sender is Control { DataContext: string sha })
{
Expand Down
1 change: 1 addition & 0 deletions src/Views/CommitDetail.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
SignInfo="{Binding SignInfo}"
SupportsContainsIn="True"
WebLinks="{Binding WebLinks}"
Children="{Binding Children}"
IssueTrackerRules="{Binding IssueTrackerRules}"/>

<!-- Line -->
Expand Down