mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: hover on tag view shows the message of it (#567)
This commit is contained in:
parent
9ed5226eab
commit
f6e0b0b1c0
5 changed files with 67 additions and 57 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
{
|
||||
public string Name { get; set; }
|
||||
public string SHA { get; set; }
|
||||
public string Message { get; set; }
|
||||
public bool IsFiltered { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue