Skip to content

Commit 7ba35e1

Browse files
committed
feature: add children list to the commit base info view
Useful for navigation between the commits.
1 parent b974436 commit 7ba35e1

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed

src/Commands/QueryCommits.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ public QueryCommits(string repo, string filter, Models.CommitSearchMethod method
104104
if (_findFirstMerged && !_isHeadFounded && _commits.Count > 0)
105105
MarkFirstMerged();
106106

107+
foreach (var commit in _commits)
108+
{
109+
foreach (var parent in _commits.FindAll(c => commit.Parents.Contains(c.SHA)))
110+
{
111+
parent.Children.Add(commit.SHA);
112+
}
113+
}
114+
107115
return _commits;
108116
}
109117

src/Models/Commit.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static double OpacityForNotMerged
2828
public ulong CommitterTime { get; set; } = 0;
2929
public string Subject { get; set; } = string.Empty;
3030
public List<string> Parents { get; set; } = new List<string>();
31+
public List<string> Children { get; set; } = new List<string>();
3132
public List<Decorator> Decorators { get; set; } = new List<Decorator>();
3233
public bool HasDecorators => Decorators.Count > 0;
3334

src/Resources/Locales/en_US.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
<x:String x:Key="Text.CommitDetail.Info" xml:space="preserve">INFORMATION</x:String>
126126
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">AUTHOR</x:String>
127127
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">CHANGED</x:String>
128+
<x:String x:Key="Text.CommitDetail.Info.Children" xml:space="preserve">CHILDREN</x:String>
128129
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">COMMITTER</x:String>
129130
<x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">Check refs that contains this commit</x:String>
130131
<x:String x:Key="Text.CommitDetail.Info.ContainsIn.Title" xml:space="preserve">COMMIT IS CONTAINED BY</x:String>

src/Views/CommitBaseInfo.axaml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<Rectangle Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/>
5252

5353
<!-- Base Information -->
54-
<Grid RowDefinitions="24,Auto,Auto,Auto" ColumnDefinitions="96,*">
54+
<Grid RowDefinitions="24,Auto,Auto,Auto,Auto" ColumnDefinitions="96,*">
5555
<!-- SHA -->
5656
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
5757
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
@@ -101,7 +101,7 @@
101101
</StackPanel>
102102

103103
<!-- PARENTS -->
104-
<TextBlock Grid.Row="1" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/>
104+
<TextBlock Grid.Row="1" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Parents}"/>
105105
<ItemsControl Grid.Row="1" Grid.Column="1" Height="24" Margin="12,0,0,0" ItemsSource="{Binding Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
106106
<ItemsControl.ItemsPanel>
107107
<ItemsPanelTemplate>
@@ -117,14 +117,36 @@
117117
TextDecorations="Underline"
118118
Cursor="Hand"
119119
Margin="0,0,16,0"
120-
PointerPressed="OnParentSHAPressed"/>
120+
PointerPressed="OnSHAPressed"/>
121+
</DataTemplate>
122+
</ItemsControl.ItemTemplate>
123+
</ItemsControl>
124+
125+
<!-- CHILDREN -->
126+
<TextBlock Grid.Row="2" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Children}"/>
127+
<ItemsControl Grid.Row="2" Grid.Column="1" Height="24" Margin="12,0,0,0" ItemsSource="{Binding Children}" IsVisible="{Binding Children.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}">
128+
<ItemsControl.ItemsPanel>
129+
<ItemsPanelTemplate>
130+
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"/>
131+
</ItemsPanelTemplate>
132+
</ItemsControl.ItemsPanel>
133+
134+
<ItemsControl.ItemTemplate>
135+
<DataTemplate>
136+
<TextBlock Classes="primary"
137+
Text="{Binding Converter={x:Static c:StringConverters.ToShortSHA}}"
138+
Foreground="DarkOrange"
139+
TextDecorations="Underline"
140+
Cursor="Hand"
141+
Margin="0,0,16,0"
142+
PointerPressed="OnSHAPressed"/>
121143
</DataTemplate>
122144
</ItemsControl.ItemTemplate>
123145
</ItemsControl>
124146

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

136158
<!-- Messages -->
137-
<TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Message}" VerticalAlignment="Top" Margin="0,4,0,0" />
138-
<v:CommitMessagePresenter Grid.Row="3" Grid.Column="1"
159+
<TextBlock Grid.Row="4" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Message}" VerticalAlignment="Top" Margin="0,4,0,0" />
160+
<v:CommitMessagePresenter Grid.Row="4" Grid.Column="1"
139161
Margin="12,5,8,0"
140162
Classes="primary"
141163
Message="{Binding #ThisControl.Message}"

src/Views/CommitBaseInfo.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private void OnOpenContainsIn(object sender, RoutedEventArgs e)
113113
e.Handled = true;
114114
}
115115

116-
private void OnParentSHAPressed(object sender, PointerPressedEventArgs e)
116+
private void OnSHAPressed(object sender, PointerPressedEventArgs e)
117117
{
118118
if (DataContext is ViewModels.CommitDetail detail && sender is Control { DataContext: string sha })
119119
{

0 commit comments

Comments
 (0)