mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: add a button to see which branches and tags that contains selected commit (#388)
This commit is contained in:
parent
fcc8a41ad1
commit
6ab0900b20
14 changed files with 171 additions and 18 deletions
37
src/Commands/QueryRefsContainsCommit.cs
Normal file
37
src/Commands/QueryRefsContainsCommit.cs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SourceGit.Commands
|
||||||
|
{
|
||||||
|
public class QueryRefsContainsCommit : Command
|
||||||
|
{
|
||||||
|
public QueryRefsContainsCommit(string repo, string commit)
|
||||||
|
{
|
||||||
|
WorkingDirectory = repo;
|
||||||
|
RaiseError = false;
|
||||||
|
Args = $"for-each-ref --format=\"%(refname)\" --contains {commit}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Models.Decorator> Result()
|
||||||
|
{
|
||||||
|
var rs = new List<Models.Decorator>();
|
||||||
|
|
||||||
|
var output = ReadToEnd();
|
||||||
|
if (!output.IsSuccess)
|
||||||
|
return rs;
|
||||||
|
|
||||||
|
var lines = output.StdOut.Split('\n');
|
||||||
|
foreach (var line in lines)
|
||||||
|
{
|
||||||
|
if (line.StartsWith("refs/heads/", StringComparison.Ordinal))
|
||||||
|
rs.Add(new() { Name = line.Substring("refs/heads/".Length), Type = Models.DecoratorType.LocalBranchHead });
|
||||||
|
else if (line.StartsWith("refs/remotes/", StringComparison.Ordinal))
|
||||||
|
rs.Add(new() { Name = line.Substring("refs/remotes/".Length), Type = Models.DecoratorType.RemoteBranchHead });
|
||||||
|
else if (line.StartsWith("refs/tags/", StringComparison.Ordinal))
|
||||||
|
rs.Add(new() { Name = line.Substring("refs/tags/".Length), Type = Models.DecoratorType.Tag });
|
||||||
|
}
|
||||||
|
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,5 +14,6 @@
|
||||||
{
|
{
|
||||||
public DecoratorType Type { get; set; } = DecoratorType.None;
|
public DecoratorType Type { get; set; } = DecoratorType.None;
|
||||||
public string Name { get; set; } = "";
|
public string Name { get; set; } = "";
|
||||||
|
public bool IsTag => Type == DecoratorType.Tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
<StreamGeometry x:Key="Icons.Pull">M432 0h160c27 0 48 21 48 48v336h175c36 0 53 43 28 68L539 757c-15 15-40 15-55 0L180 452c-25-25-7-68 28-68H384V48c0-27 21-48 48-48zm592 752v224c0 27-21 48-48 48H48c-27 0-48-21-48-48V752c0-27 21-48 48-48h293l98 98c40 40 105 40 145 0l98-98H976c27 0 48 21 48 48zm-248 176c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40zm128 0c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Pull">M432 0h160c27 0 48 21 48 48v336h175c36 0 53 43 28 68L539 757c-15 15-40 15-55 0L180 452c-25-25-7-68 28-68H384V48c0-27 21-48 48-48zm592 752v224c0 27-21 48-48 48H48c-27 0-48-21-48-48V752c0-27 21-48 48-48h293l98 98c40 40 105 40 145 0l98-98H976c27 0 48 21 48 48zm-248 176c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40zm128 0c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40z</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.Push">M592 768h-160c-27 0-48-21-48-48V384h-175c-36 0-53-43-28-68L485 11c15-15 40-15 55 0l304 304c25 25 7 68-28 68H640v336c0 27-21 48-48 48zm432-16v224c0 27-21 48-48 48H48c-27 0-48-21-48-48V752c0-27 21-48 48-48h272v16c0 62 50 112 112 112h160c62 0 112-50 112-112v-16h272c27 0 48 21 48 48zm-248 176c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40zm128 0c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Push">M592 768h-160c-27 0-48-21-48-48V384h-175c-36 0-53-43-28-68L485 11c15-15 40-15 55 0l304 304c25 25 7 68-28 68H640v336c0 27-21 48-48 48zm432-16v224c0 27-21 48-48 48H48c-27 0-48-21-48-48V752c0-27 21-48 48-48h272v16c0 62 50 112 112 112h160c62 0 112-50 112-112v-16h272c27 0 48 21 48 48zm-248 176c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40zm128 0c0-22-18-40-40-40s-40 18-40 40s18 40 40 40s40-18 40-40z</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.Rebase">M277 85a149 149 0 00-43 292v230a32 32 0 0064 0V555h267A160 160 0 00725 395v-12a149 149 0 10-64-5v17a96 96 0 01-96 96H299V383A149 149 0 00277 85zM228 720a32 32 0 00-37-52 150 150 0 00-53 68 32 32 0 1060 23 85 85 0 0130-39zm136-52a32 32 0 00-37 52 86 86 0 0130 39 32 32 0 1060-23 149 149 0 00-53-68zM204 833a32 32 0 10-55 32 149 149 0 0063 58 32 32 0 0028-57 85 85 0 01-36-33zm202 32a32 32 0 00-55-32 85 85 0 01-36 33 32 32 0 0028 57 149 149 0 0063-58z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Rebase">M277 85a149 149 0 00-43 292v230a32 32 0 0064 0V555h267A160 160 0 00725 395v-12a149 149 0 10-64-5v17a96 96 0 01-96 96H299V383A149 149 0 00277 85zM228 720a32 32 0 00-37-52 150 150 0 00-53 68 32 32 0 1060 23 85 85 0 0130-39zm136-52a32 32 0 00-37 52 86 86 0 0130 39 32 32 0 1060-23 149 149 0 00-53-68zM204 833a32 32 0 10-55 32 149 149 0 0063 58 32 32 0 0028-57 85 85 0 01-36-33zm202 32a32 32 0 00-55-32 85 85 0 01-36 33 32 32 0 0028 57 149 149 0 0063-58z</StreamGeometry>
|
||||||
|
<StreamGeometry x:Key="Icons.Relation">M672 336l64-89c-13-19-26-45-26-70 0-64 51-115 109-115s109 51 109 115-51 115-109 115c-19 0-38-6-51-13l-64 89c32 38 51 89 51 147 0 70-32 128-77 172l51 64c13-6 32-13 51-13 57 0 109 51 109 115s-51 109-109 109-109-51-109-115c0-26 13-51 26-70L646 707c-32 19-64 26-102 26-121 0-217-102-217-223v-38l-57-13c-19 32-57 57-96 57C116 515 65 464 65 400s51-115 109-115 109 51 109 115v13l57 19C372 349 448 292 538 292c51 0 102 19 134 45z</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.Remote">M706 302a289 289 0 00-173 44 27 27 0 1029 46 234 234 0 01125-36c23 0 45 3 66 9 93 28 161 114 161 215C914 704 813 805 687 805H337C211 805 110 704 110 580c0-96 61-178 147-210C282 263 379 183 495 183a245 245 0 01210 119z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Remote">M706 302a289 289 0 00-173 44 27 27 0 1029 46 234 234 0 01125-36c23 0 45 3 66 9 93 28 161 114 161 215C914 704 813 805 687 805H337C211 805 110 704 110 580c0-96 61-178 147-210C282 263 379 183 495 183a245 245 0 01210 119z</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.Remote.Add">M364 512h67v108h108v67h-108v108h-67v-108h-108v-67h108v-108zm298-64A107 107 0 01768 555C768 614 720 660 660 660h-108v-54h-108v-108h-94v108h-94c4-21 22-47 44-51l-1-12a75 75 0 0171-75a128 128 0 01239-7a106 106 0 0153-14z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Remote.Add">M364 512h67v108h108v67h-108v108h-67v-108h-108v-67h108v-108zm298-64A107 107 0 01768 555C768 614 720 660 660 660h-108v-54h-108v-108h-94v108h-94c4-21 22-47 44-51l-1-12a75 75 0 0171-75a128 128 0 01239-7a106 106 0 0153-14z</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.RemoveAll">M1024 64v704h-128v128h-128v128h-768v-704h128v-128h128v-128zM64 960h640v-576h-640zM320 128v64h576v512h64v-576zM192 256v64h576v512h64v-576zM432 688L576 832H480L384 736 288 832H192l144-144L192 544h96L384 640l96-96H576z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.RemoveAll">M1024 64v704h-128v128h-128v128h-768v-704h128v-128h128v-128zM64 960h640v-576h-640zM320 128v64h576v512h64v-576zM192 256v64h576v512h64v-576zM432 688L576 832H480L384 736 288 832H192l144-144L192 544h96L384 640l96-96H576z</StreamGeometry>
|
||||||
|
|
|
@ -116,6 +116,7 @@
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">AUTHOR</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.Changed" xml:space="preserve">CHANGED</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">COMMITTER</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.GotoChangesPage" xml:space="preserve">Shows only the first 100 changes. See all changes on the CHANGES tab.</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.GotoChangesPage" xml:space="preserve">Shows only the first 100 changes. See all changes on the CHANGES tab.</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Message" xml:space="preserve">MESSAGE</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Message" xml:space="preserve">MESSAGE</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">PARENTS</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">PARENTS</x:String>
|
||||||
|
|
|
@ -119,6 +119,7 @@
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">修改者</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">修改者</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">变更列表</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">变更列表</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交者</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交者</x:String>
|
||||||
|
<x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">查看包含此提交的分支/标签</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.GotoChangesPage" xml:space="preserve">仅显示前100项变更。请前往【变更对比】页面查看全部。</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.GotoChangesPage" xml:space="preserve">仅显示前100项变更。请前往【变更对比】页面查看全部。</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Message" xml:space="preserve">提交信息</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Message" xml:space="preserve">提交信息</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">父提交</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">父提交</x:String>
|
||||||
|
|
|
@ -119,6 +119,7 @@
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">修改者</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Author" xml:space="preserve">修改者</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">變更列表</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Changed" xml:space="preserve">變更列表</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交者</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Committer" xml:space="preserve">提交者</x:String>
|
||||||
|
<x:String x:Key="Text.CommitDetail.Info.ContainsIn" xml:space="preserve">查看包含此提交的分支/標籤</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.GotoChangesPage" xml:space="preserve">僅顯示前100項變更。 請前往『變更對比』頁面查看全部。</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.GotoChangesPage" xml:space="preserve">僅顯示前100項變更。 請前往『變更對比』頁面查看全部。</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Message" xml:space="preserve">提交資訊</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Message" xml:space="preserve">提交資訊</x:String>
|
||||||
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">父提交</x:String>
|
<x:String x:Key="Text.CommitDetail.Info.Parents" xml:space="preserve">父提交</x:String>
|
||||||
|
|
|
@ -141,6 +141,11 @@ namespace SourceGit.ViewModels
|
||||||
_repo?.NavigateToCommit(commitSHA);
|
_repo?.NavigateToCommit(commitSHA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Models.Decorator> GetRefsContainsThisCommit()
|
||||||
|
{
|
||||||
|
return new Commands.QueryRefsContainsCommit(_repo.FullPath, _commit.SHA).Result();
|
||||||
|
}
|
||||||
|
|
||||||
public void ClearSearchChangeFilter()
|
public void ClearSearchChangeFilter()
|
||||||
{
|
{
|
||||||
SearchChangeFilter = string.Empty;
|
SearchChangeFilter = string.Empty;
|
||||||
|
@ -460,14 +465,18 @@ namespace SourceGit.ViewModels
|
||||||
if (_commit == null)
|
if (_commit == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
var fullMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, _commit.SHA).Result();
|
||||||
|
Dispatcher.UIThread.Invoke(() => FullMessage = fullMessage);
|
||||||
|
});
|
||||||
|
|
||||||
if (_cancelToken != null)
|
if (_cancelToken != null)
|
||||||
_cancelToken.Requested = true;
|
_cancelToken.Requested = true;
|
||||||
|
|
||||||
_cancelToken = new Commands.Command.CancelToken();
|
_cancelToken = new Commands.Command.CancelToken();
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
var fullMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, _commit.SHA).Result();
|
|
||||||
var parent = _commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : _commit.Parents[0];
|
var parent = _commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : _commit.Parents[0];
|
||||||
var cmdChanges = new Commands.CompareRevisions(_repo.FullPath, parent, _commit.SHA) { Cancel = _cancelToken };
|
var cmdChanges = new Commands.CompareRevisions(_repo.FullPath, parent, _commit.SHA) { Cancel = _cancelToken };
|
||||||
var changes = cmdChanges.Result();
|
var changes = cmdChanges.Result();
|
||||||
|
@ -486,7 +495,6 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Post(() =>
|
Dispatcher.UIThread.Post(() =>
|
||||||
{
|
{
|
||||||
FullMessage = fullMessage;
|
|
||||||
Changes = changes;
|
Changes = changes;
|
||||||
VisibleChanges = visible;
|
VisibleChanges = visible;
|
||||||
});
|
});
|
||||||
|
|
|
@ -57,12 +57,16 @@
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
||||||
<SelectableTextBlock Classes="primary"
|
<SelectableTextBlock Classes="primary"
|
||||||
Text="{Binding SHA}"
|
Text="{Binding SHA}"
|
||||||
Margin="12,0,0,0"
|
Margin="12,0,4,0"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
|
|
||||||
<Button Classes="icon_button" Cursor="Hand" Click="OnOpenWebLink" IsVisible="{Binding #ThisControl.WebLinks, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}">
|
<Button Classes="icon_button" Width="24" Cursor="Hand" Click="OnOpenWebLink" IsVisible="{Binding #ThisControl.WebLinks, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}">
|
||||||
<Path Width="12" Height="12" Data="{StaticResource Icons.Link}" Fill="{DynamicResource Brush.Link}"/>
|
<Path Width="12" Height="12" Data="{StaticResource Icons.Link}" Fill="{DynamicResource Brush.Link}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<Button Classes="icon_button" Width="24" Cursor="Hand" Click="OnOpenContainsIn" IsVisible="{Binding #ThisControl.SupportsContainsIn}" ToolTip.Tip="{DynamicResource Text.CommitDetail.Info.ContainsIn}">
|
||||||
|
<Path Width="12" Height="12" Data="{StaticResource Icons.Relation}"/>
|
||||||
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,7 +102,8 @@
|
||||||
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
||||||
FontFamily="{DynamicResource Fonts.Monospace}"
|
FontFamily="{DynamicResource Fonts.Monospace}"
|
||||||
FontSize="10"
|
FontSize="10"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"
|
||||||
|
Refs="{Binding Decorators}"/>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- Messages -->
|
<!-- Messages -->
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Collections;
|
using Avalonia.Collections;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
@ -17,6 +19,15 @@ namespace SourceGit.Views
|
||||||
set => SetValue(MessageProperty, value);
|
set => SetValue(MessageProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<bool> SupportsContainsInProperty =
|
||||||
|
AvaloniaProperty.Register<CommitBaseInfo, bool>(nameof(SupportsContainsIn));
|
||||||
|
|
||||||
|
public bool SupportsContainsIn
|
||||||
|
{
|
||||||
|
get => GetValue(SupportsContainsInProperty);
|
||||||
|
set => SetValue(SupportsContainsInProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<AvaloniaList<Models.CommitLink>> WebLinksProperty =
|
public static readonly StyledProperty<AvaloniaList<Models.CommitLink>> WebLinksProperty =
|
||||||
AvaloniaProperty.Register<CommitBaseInfo, AvaloniaList<Models.CommitLink>>(nameof(WebLinks));
|
AvaloniaProperty.Register<CommitBaseInfo, AvaloniaList<Models.CommitLink>>(nameof(WebLinks));
|
||||||
|
|
||||||
|
@ -74,6 +85,19 @@ namespace SourceGit.Views
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnOpenContainsIn(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (DataContext is ViewModels.CommitDetail detail && sender is Button button)
|
||||||
|
{
|
||||||
|
var tracking = new CommitRelationTracking(detail);
|
||||||
|
var flyout = new Flyout();
|
||||||
|
flyout.Content = tracking;
|
||||||
|
flyout.ShowAt(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnParentSHAPressed(object sender, PointerPressedEventArgs e)
|
private void OnParentSHAPressed(object sender, PointerPressedEventArgs e)
|
||||||
{
|
{
|
||||||
if (DataContext is ViewModels.CommitDetail detail && sender is Control { DataContext: string sha })
|
if (DataContext is ViewModels.CommitDetail detail && sender is Control { DataContext: string sha })
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
<!-- Base Information -->
|
<!-- Base Information -->
|
||||||
<v:CommitBaseInfo Content="{Binding Commit}"
|
<v:CommitBaseInfo Content="{Binding Commit}"
|
||||||
Message="{Binding FullMessage}"
|
Message="{Binding FullMessage}"
|
||||||
|
SupportsContainsIn="True"
|
||||||
WebLinks="{Binding WebLinks}"
|
WebLinks="{Binding WebLinks}"
|
||||||
IssueTrackerRules="{Binding IssueTrackerRules}"/>
|
IssueTrackerRules="{Binding IssueTrackerRules}"/>
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,15 @@ namespace SourceGit.Views
|
||||||
public bool IsTag { get; set; } = false;
|
public bool IsTag { get; set; } = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<List<Models.Decorator>> RefsProperty =
|
||||||
|
AvaloniaProperty.Register<CommitRefsPresenter, List<Models.Decorator>>(nameof(Refs));
|
||||||
|
|
||||||
|
public List<Models.Decorator> Refs
|
||||||
|
{
|
||||||
|
get => GetValue(RefsProperty);
|
||||||
|
set => SetValue(RefsProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<FontFamily> FontFamilyProperty =
|
public static readonly StyledProperty<FontFamily> FontFamilyProperty =
|
||||||
TextBlock.FontFamilyProperty.AddOwner<CommitRefsPresenter>();
|
TextBlock.FontFamilyProperty.AddOwner<CommitRefsPresenter>();
|
||||||
|
|
||||||
|
@ -85,7 +94,8 @@ namespace SourceGit.Views
|
||||||
AffectsMeasure<CommitRefsPresenter>(
|
AffectsMeasure<CommitRefsPresenter>(
|
||||||
FontFamilyProperty,
|
FontFamilyProperty,
|
||||||
FontSizeProperty,
|
FontSizeProperty,
|
||||||
LabelForegroundProperty);
|
LabelForegroundProperty,
|
||||||
|
RefsProperty);
|
||||||
|
|
||||||
AffectsRender<CommitRefsPresenter>(
|
AffectsRender<CommitRefsPresenter>(
|
||||||
IconBackgroundProperty,
|
IconBackgroundProperty,
|
||||||
|
@ -121,17 +131,12 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDataContextChanged(EventArgs e)
|
|
||||||
{
|
|
||||||
base.OnDataContextChanged(e);
|
|
||||||
InvalidateMeasure();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Size MeasureOverride(Size availableSize)
|
protected override Size MeasureOverride(Size availableSize)
|
||||||
{
|
{
|
||||||
_items.Clear();
|
_items.Clear();
|
||||||
|
|
||||||
if (DataContext is Models.Commit commit && commit.HasDecorators)
|
var refs = Refs;
|
||||||
|
if (refs != null && refs.Count > 0)
|
||||||
{
|
{
|
||||||
var typeface = new Typeface(FontFamily);
|
var typeface = new Typeface(FontFamily);
|
||||||
var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold);
|
var typefaceBold = new Typeface(FontFamily, FontStyle.Normal, FontWeight.Bold);
|
||||||
|
@ -139,7 +144,7 @@ namespace SourceGit.Views
|
||||||
var labelSize = FontSize;
|
var labelSize = FontSize;
|
||||||
var requiredWidth = 0.0;
|
var requiredWidth = 0.0;
|
||||||
|
|
||||||
foreach (var decorator in commit.Decorators)
|
foreach (var decorator in refs)
|
||||||
{
|
{
|
||||||
var isHead = decorator.Type == Models.DecoratorType.CurrentBranchHead ||
|
var isHead = decorator.Type == Models.DecoratorType.CurrentBranchHead ||
|
||||||
decorator.Type == Models.DecoratorType.CurrentCommitHead;
|
decorator.Type == Models.DecoratorType.CurrentCommitHead;
|
||||||
|
|
36
src/Views/CommitRelationTracking.axaml
Normal file
36
src/Views/CommitRelationTracking.axaml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:m="using:SourceGit.Models"
|
||||||
|
xmlns:v="using:SourceGit.Views"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="SourceGit.Views.CommitRelationTracking">
|
||||||
|
<Grid RowDefinitions="Auto,Auto,Auto">
|
||||||
|
<TextBlock Grid.Row="0" Classes="info_label" Text="COMMIT CONTAINS IN" HorizontalAlignment="Center"/>
|
||||||
|
<Rectangle Grid.Row="1" Height="1" HorizontalAlignment="Stretch" Margin="0,8" Fill="{DynamicResource Brush.Border2}"/>
|
||||||
|
<ScrollViewer Grid.Row="2" MinWidth="300" MaxWidth="500" MaxHeight="200" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||||
|
<ItemsControl x:Name="Container">
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<WrapPanel Orientation="Horizontal"/>
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate DataType="m:Decorator">
|
||||||
|
<Border Height="20" Margin="0,4,6,0" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}" CornerRadius="12">
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="8,0" VerticalAlignment="Center">
|
||||||
|
<Path Width="10" Height="10" Data="{StaticResource Icons.Branch}" IsVisible="{Binding !IsTag}"/>
|
||||||
|
<Path Width="10" Height="10" Data="{StaticResource Icons.Tag}" IsVisible="{Binding IsTag}"/>
|
||||||
|
<TextBlock Classes="primary" Text="{Binding Name}" Margin="2,0,0,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
|
<v:LoadingIcon x:Name="LoadingIcon" Grid.Row="2" HorizontalAlignment="Center" Margin="0,16" Width="24" Height="24" IsVisible="False"/>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
32
src/Views/CommitRelationTracking.axaml.cs
Normal file
32
src/Views/CommitRelationTracking.axaml.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
|
||||||
|
namespace SourceGit.Views
|
||||||
|
{
|
||||||
|
public partial class CommitRelationTracking : UserControl
|
||||||
|
{
|
||||||
|
public CommitRelationTracking()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommitRelationTracking(ViewModels.CommitDetail detail)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
LoadingIcon.IsVisible = true;
|
||||||
|
|
||||||
|
Task.Run(() =>
|
||||||
|
{
|
||||||
|
var containsIn = detail.GetRefsContainsThisCommit();
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
{
|
||||||
|
Container.ItemsSource = containsIn;
|
||||||
|
LoadingIcon.IsVisible = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -67,15 +67,15 @@
|
||||||
BehindBrush="{DynamicResource Brush.FG1}"
|
BehindBrush="{DynamicResource Brush.FG1}"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
|
|
||||||
<v:CommitRefsPresenter IsVisible="{Binding HasDecorators}"
|
<v:CommitRefsPresenter IconBackground="{DynamicResource Brush.DecoratorIconBG}"
|
||||||
IconBackground="{DynamicResource Brush.DecoratorIconBG}"
|
|
||||||
IconForeground="{DynamicResource Brush.DecoratorIcon}"
|
IconForeground="{DynamicResource Brush.DecoratorIcon}"
|
||||||
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
|
BranchNameBackground="{DynamicResource Brush.DecoratorBranch}"
|
||||||
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
|
TagNameBackground="{DynamicResource Brush.DecoratorTag}"
|
||||||
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
LabelForeground="{DynamicResource Brush.DecoratorFG}"
|
||||||
FontFamily="{DynamicResource Fonts.Monospace}"
|
FontFamily="{DynamicResource Fonts.Monospace}"
|
||||||
FontSize="10"
|
FontSize="10"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"
|
||||||
|
Refs="{Binding Decorators}"/>
|
||||||
|
|
||||||
<v:CommitSubjectPresenter Classes="primary"
|
<v:CommitSubjectPresenter Classes="primary"
|
||||||
Subject="{Binding Subject}"
|
Subject="{Binding Subject}"
|
||||||
|
|
Loading…
Reference in a new issue