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)
|
public QueryTags(string repo)
|
||||||
{
|
{
|
||||||
|
_boundary = $"----- BOUNDARY OF TAGS {Guid.NewGuid()} -----";
|
||||||
|
|
||||||
Context = repo;
|
Context = repo;
|
||||||
WorkingDirectory = 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()
|
public List<Models.Tag> Result()
|
||||||
|
@ -19,27 +21,25 @@ namespace SourceGit.Commands
|
||||||
if (!rs.IsSuccess)
|
if (!rs.IsSuccess)
|
||||||
return tags;
|
return tags;
|
||||||
|
|
||||||
var lines = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries);
|
var records = rs.StdOut.Split(_boundary, StringSplitOptions.RemoveEmptyEntries);
|
||||||
foreach (var line in lines)
|
foreach (var record in records)
|
||||||
{
|
{
|
||||||
var tag = ParseLine(line);
|
var subs = record.Split('\0', StringSplitOptions.None);
|
||||||
if (tag != null)
|
if (subs.Length != 4)
|
||||||
tags.Add(tag);
|
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;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Models.Tag ParseLine(string line)
|
private string _boundary = string.Empty;
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string SHA { get; set; }
|
public string SHA { get; set; }
|
||||||
|
public string Message { get; set; }
|
||||||
public bool IsFiltered { get; set; }
|
public bool IsFiltered { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,11 @@ namespace SourceGit.ViewModels
|
||||||
public Models.Tag Tag { get; private set; } = null;
|
public Models.Tag Tag { get; private set; } = null;
|
||||||
public List<TagTreeNode> Children { get; private set; } = [];
|
public List<TagTreeNode> Children { get; private set; } = [];
|
||||||
|
|
||||||
|
public object ToolTip
|
||||||
|
{
|
||||||
|
get => Tag?.Message;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsFolder
|
public bool IsFolder
|
||||||
{
|
{
|
||||||
get => Tag == null;
|
get => Tag == null;
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
|
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
ContextRequested="OnRowContextRequested"
|
ContextRequested="OnRowContextRequested"
|
||||||
DoubleTapped="OnDoubleTappedNode">
|
DoubleTapped="OnDoubleTappedNode"
|
||||||
|
ToolTip.Tip="{Binding ToolTip}">
|
||||||
<v:TagTreeNodeToggleButton Grid.Column="0"
|
<v:TagTreeNodeToggleButton Grid.Column="0"
|
||||||
Classes="tree_expander"
|
Classes="tree_expander"
|
||||||
Focusable="False"
|
Focusable="False"
|
||||||
|
@ -64,7 +65,10 @@
|
||||||
SelectionChanged="OnRowSelectionChanged">
|
SelectionChanged="OnRowSelectionChanged">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate DataType="m:Tag">
|
<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"
|
<Path Grid.Column="0"
|
||||||
Width="10" Height="10"
|
Width="10" Height="10"
|
||||||
Margin="8,0,0,0"
|
Margin="8,0,0,0"
|
||||||
|
|
Loading…
Reference in a new issue