feature: hover on tag view shows the message of it (#567)

This commit is contained in:
leo 2024-10-17 14:57:05 +08:00
parent 9ed5226eab
commit f6e0b0b1c0
No known key found for this signature in database
5 changed files with 67 additions and 57 deletions

View file

@ -7,9 +7,11 @@ namespace SourceGit.Commands
{
public QueryTags(string repo)
{
_boundary = $"----- BOUNDARY OF TAGS {Guid.NewGuid()} -----";
Context = repo;
WorkingDirectory = repo;
Args = "tag -l --sort=-creatordate --format=\"%(refname)%00%(objectname)%00%(*objectname)\"";
Args = $"tag -l --sort=-creatordate --format=\"{_boundary}%(refname)%00%(objectname)%00%(*objectname)%00%(contents:subject)%0a%0a%(contents:body)\"";
}
public List<Models.Tag> Result()
@ -19,27 +21,25 @@ namespace SourceGit.Commands
if (!rs.IsSuccess)
return tags;
var lines = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries);
foreach (var line in lines)
var records = rs.StdOut.Split(_boundary, StringSplitOptions.RemoveEmptyEntries);
foreach (var record in records)
{
var tag = ParseLine(line);
if (tag != null)
tags.Add(tag);
var subs = record.Split('\0', StringSplitOptions.None);
if (subs.Length != 4)
continue;
var message = subs[3].Trim();
tags.Add(new Models.Tag()
{
Name = subs[0].Substring(10),
SHA = string.IsNullOrEmpty(subs[2]) ? subs[1] : subs[2],
Message = string.IsNullOrEmpty(message) ? null : message,
});
}
return tags;
}
private Models.Tag ParseLine(string line)
{
var subs = line.Split('\0');
if (subs.Length != 3)
return null;
var tag = new Models.Tag();
tag.Name = subs[0].Substring(10);
tag.SHA = string.IsNullOrEmpty(subs[2]) ? subs[1] : subs[2];
return tag;
}
private string _boundary = string.Empty;
}
}

View file

@ -4,6 +4,7 @@
{
public string Name { get; set; }
public string SHA { get; set; }
public string Message { get; set; }
public bool IsFiltered { get; set; }
}
}

View file

@ -12,6 +12,11 @@ namespace SourceGit.ViewModels
public Models.Tag Tag { get; private set; } = null;
public List<TagTreeNode> Children { get; private set; } = [];
public object ToolTip
{
get => Tag?.Message;
}
public bool IsFolder
{
get => Tag == null;

View file

@ -33,49 +33,49 @@
ColumnDefinitions="16,*"
ToolTip.Tip="{Binding Tooltip}">
<!-- Tree Expander -->
<v:BranchTreeNodeToggleButton Grid.Column="0"
Classes="tree_expander"
Focusable="False"
HorizontalAlignment="Center"
IsChecked="{Binding IsExpanded, Mode=OneWay}"
IsVisible="{Binding !IsBranch}"/>
<!-- Tree Expander -->
<v:BranchTreeNodeToggleButton Grid.Column="0"
Classes="tree_expander"
Focusable="False"
HorizontalAlignment="Center"
IsChecked="{Binding IsExpanded, Mode=OneWay}"
IsVisible="{Binding !IsBranch}"/>
<!-- Content Area (allows double-click) -->
<Grid Grid.Column="1"
Background="Transparent"
ColumnDefinitions="18,*,Auto,Auto"
DoubleTapped="OnDoubleTappedBranchNode">
<!-- Content Area (allows double-click) -->
<Grid Grid.Column="1"
Background="Transparent"
ColumnDefinitions="18,*,Auto,Auto"
DoubleTapped="OnDoubleTappedBranchNode">
<!-- Icon -->
<v:BranchTreeNodeIcon Grid.Column="0"
Node="{Binding}"
IsExpanded="{Binding IsExpanded}"/>
<!-- Icon -->
<v:BranchTreeNodeIcon Grid.Column="0"
Node="{Binding}"
IsExpanded="{Binding IsExpanded}"/>
<!-- Name -->
<TextBlock Grid.Column="1"
Text="{Binding Name}"
Classes="primary"
FontWeight="{Binding NameFontWeight}"
TextTrimming="CharacterEllipsis"/>
<!-- Name -->
<TextBlock Grid.Column="1"
Text="{Binding Name}"
Classes="primary"
FontWeight="{Binding NameFontWeight}"
TextTrimming="CharacterEllipsis"/>
<!-- Tracking status -->
<v:BranchTreeNodeTrackStatusPresenter Grid.Column="2"
VerticalAlignment="Center"
FontFamily="{DynamicResource Fonts.Monospace}"
FontSize="10"
Foreground="{DynamicResource Brush.BadgeFG}"
Background="{DynamicResource Brush.Badge}"/>
<!-- Tracking status -->
<v:BranchTreeNodeTrackStatusPresenter Grid.Column="2"
VerticalAlignment="Center"
FontFamily="{DynamicResource Fonts.Monospace}"
FontSize="10"
Foreground="{DynamicResource Brush.BadgeFG}"
Background="{DynamicResource Brush.Badge}"/>
<!-- Filter Toggle Button -->
<ToggleButton Grid.Column="3"
Classes="filter"
Margin="0,0,8,0"
Background="Transparent"
IsVisible="{Binding IsBranch}"
IsChecked="{Binding IsFiltered}"
Click="OnToggleFilterClicked"
ToolTip.Tip="{DynamicResource Text.Filter}"/>
<!-- Filter Toggle Button -->
<ToggleButton Grid.Column="3"
Classes="filter"
Margin="0,0,8,0"
Background="Transparent"
IsVisible="{Binding IsBranch}"
IsChecked="{Binding IsFiltered}"
Click="OnToggleFilterClicked"
ToolTip.Tip="{DynamicResource Text.Filter}"/>
</Grid>
</Grid>
</DataTemplate>

View file

@ -26,7 +26,8 @@
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
Background="Transparent"
ContextRequested="OnRowContextRequested"
DoubleTapped="OnDoubleTappedNode">
DoubleTapped="OnDoubleTappedNode"
ToolTip.Tip="{Binding ToolTip}">
<v:TagTreeNodeToggleButton Grid.Column="0"
Classes="tree_expander"
Focusable="False"
@ -64,7 +65,10 @@
SelectionChanged="OnRowSelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate DataType="m:Tag">
<Grid ColumnDefinitions="Auto,*,Auto" Background="Transparent" ContextRequested="OnRowContextRequested">
<Grid ColumnDefinitions="Auto,*,Auto"
Background="Transparent"
ContextRequested="OnRowContextRequested"
ToolTip.Tip="{Binding Message}">
<Path Grid.Column="0"
Width="10" Height="10"
Margin="8,0,0,0"