feature: supports the commit hash issue tracker (#382)

Using issue tracker instead of built-in supported commit web link is based on the following reasons

* repo may have multiple remotes
* it is not good to open an context menu to choose which web to visit with multiple remotes
* some remote servers are not supported by this app
This commit is contained in:
leo 2024-08-21 10:44:07 +08:00
parent 7b26589485
commit 48adad53b4
No known key found for this signature in database
6 changed files with 22 additions and 0 deletions

View file

@ -125,6 +125,19 @@ namespace SourceGit.Models
return rule;
}
public IssueTrackerRule AddCommitLinkIssueTracker()
{
var rule = new IssueTrackerRule()
{
Name = "Commit Link",
RegexString = @"\b([0-9a-fA-F]{8,40})\b",
URLTemplate = "https://test/$1",
};
IssueTrackerRules.Add(rule);
return rule;
}
public IssueTrackerRule AddGithubIssueTracker(string repoURL)
{
var rule = new IssueTrackerRule()

View file

@ -131,6 +131,7 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">Email address</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE TRACKER</x:String>
<x:String x:Key="Text.Configure.IssueTracker.AddSampleCommitLink" xml:space="preserve">Add Sample Commit HASH Rule</x:String>
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGithub" xml:space="preserve">Add Sample Github Rule</x:String>
<x:String x:Key="Text.Configure.IssueTracker.AddSampleJira" xml:space="preserve">Add Sample Jira Rule</x:String>
<x:String x:Key="Text.Configure.IssueTracker.NewRule" xml:space="preserve">New Rule</x:String>

View file

@ -134,6 +134,7 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">邮箱地址</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT配置</x:String>
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE追踪</x:String>
<x:String x:Key="Text.Configure.IssueTracker.AddSampleCommitLink" xml:space="preserve">新增匹配提交HASH规则</x:String>
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGithub" xml:space="preserve">新增匹配Github Issue规则</x:String>
<x:String x:Key="Text.Configure.IssueTracker.AddSampleJira" xml:space="preserve">新增匹配Jira规则</x:String>
<x:String x:Key="Text.Configure.IssueTracker.NewRule" xml:space="preserve">新增自定义规则</x:String>

View file

@ -134,6 +134,7 @@
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">郵箱地址</x:String>
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT配置</x:String>
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE追蹤</x:String>
<x:String x:Key="Text.Configure.IssueTracker.AddSampleCommitLink" xml:space="preserve">新增匹配提交HASH規則</x:String>
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGithub" xml:space="preserve">新增匹配Github Issue規則</x:String>
<x:String x:Key="Text.Configure.IssueTracker.AddSampleJira" xml:space="preserve">新增匹配Jira規則</x:String>
<x:String x:Key="Text.Configure.IssueTracker.NewRule" xml:space="preserve">新增自定義規則</x:String>

View file

@ -102,6 +102,11 @@ namespace SourceGit.ViewModels
SelectedCommitTemplate = null;
}
public void AddSampleCommitLinkTracker()
{
SelectedIssueTrackerRule = _repo.Settings.AddCommitLinkIssueTracker();
}
public void AddSampleGithubIssueTracker()
{
foreach (var remote in _repo.Remotes)

View file

@ -241,6 +241,7 @@
<MenuFlyout Placement="BottomEdgeAlignedLeft">
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.NewRule}" Command="{Binding NewIssueTracker}"/>
<MenuItem Header="-"/>
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleCommitLink}" Command="{Binding AddSampleCommitLinkTracker}"/>
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGithub}" Command="{Binding AddSampleGithubIssueTracker}"/>
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleJira}" Command="{Binding AddSampleJiraIssueTracker}"/>
</MenuFlyout>