mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
enhance: add GitLab Issue/MR sample rules (#598)
* enhance: add GitLab Issue/MR sample rules * fix: remove blank in zh_CN --------- Signed-off-by: Gadfly <gadfly@gadfly.vip>
This commit is contained in:
parent
d3d71af0e8
commit
c08c307c7a
6 changed files with 62 additions and 0 deletions
|
@ -169,6 +169,32 @@ namespace SourceGit.Models
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IssueTrackerRule AddGitLabIssueTracker(string repoURL)
|
||||||
|
{
|
||||||
|
var rule = new IssueTrackerRule()
|
||||||
|
{
|
||||||
|
Name = "GitLab ISSUE",
|
||||||
|
RegexString = "#(\\d+)",
|
||||||
|
URLTemplate = string.IsNullOrEmpty(repoURL) ? "https://gitlab.com/username/repository/-/issues/$1" : $"{repoURL}/-/issues/$1",
|
||||||
|
};
|
||||||
|
|
||||||
|
IssueTrackerRules.Add(rule);
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IssueTrackerRule AddGitLabMergeRequestTracker(string repoURL)
|
||||||
|
{
|
||||||
|
var rule = new IssueTrackerRule()
|
||||||
|
{
|
||||||
|
Name = "GitLab MR",
|
||||||
|
RegexString = "!(\\d+)",
|
||||||
|
URLTemplate = string.IsNullOrEmpty(repoURL) ? "https://gitlab.com/username/repository/-/merge_requests/$1" : $"{repoURL}/-/merge_requests/$1",
|
||||||
|
};
|
||||||
|
|
||||||
|
IssueTrackerRules.Add(rule);
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
public void RemoveIssueTracker(IssueTrackerRule rule)
|
public void RemoveIssueTracker(IssueTrackerRule rule)
|
||||||
{
|
{
|
||||||
if (rule != null)
|
if (rule != null)
|
||||||
|
|
|
@ -147,6 +147,8 @@
|
||||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE TRACKER</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE TRACKER</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.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.AddSampleJira" xml:space="preserve">Add Sample Jira Rule</x:String>
|
||||||
|
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGitLabIssue" xml:space="preserve">Add Sample GitLab Issue Rule</x:String>
|
||||||
|
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGitLabMergeRequest" xml:space="preserve">Add Sample GitLab Merge Request Rule</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.NewRule" xml:space="preserve">New Rule</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker.NewRule" xml:space="preserve">New Rule</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.Regex" xml:space="preserve">Issue Regex Expression:</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker.Regex" xml:space="preserve">Issue Regex Expression:</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.RuleName" xml:space="preserve">Rule Name:</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker.RuleName" xml:space="preserve">Rule Name:</x:String>
|
||||||
|
|
|
@ -150,6 +150,8 @@
|
||||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE追踪</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE追踪</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGithub" xml:space="preserve">新增匹配Github Issue规则</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.AddSampleJira" xml:space="preserve">新增匹配Jira规则</x:String>
|
||||||
|
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGitLabIssue" xml:space="preserve">新增匹配GitLab议题规则</x:String>
|
||||||
|
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGitLabMergeRequest" xml:space="preserve">新增匹配GitLab合并请求规则</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.NewRule" xml:space="preserve">新增自定义规则</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker.NewRule" xml:space="preserve">新增自定义规则</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.Regex" xml:space="preserve">匹配ISSUE的正则表达式 :</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker.Regex" xml:space="preserve">匹配ISSUE的正则表达式 :</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.RuleName" xml:space="preserve">规则名 :</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker.RuleName" xml:space="preserve">规则名 :</x:String>
|
||||||
|
|
|
@ -150,6 +150,8 @@
|
||||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">Issue 追蹤</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">Issue 追蹤</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGithub" xml:space="preserve">新增符合 GitHub Issue 規則</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.AddSampleJira" xml:space="preserve">新增符合 Jira 規則</x:String>
|
||||||
|
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGitLabIssue" xml:space="preserve">新增符合 GitLab 議題規則</x:String>
|
||||||
|
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGitLabMergeRequest" xml:space="preserve">新增符合 GitLab 合併請求規則</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.NewRule" xml:space="preserve">新增自訂規則</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker.NewRule" xml:space="preserve">新增自訂規則</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.Regex" xml:space="preserve">符合 Issue 的正則表達式:</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker.Regex" xml:space="preserve">符合 Issue 的正則表達式:</x:String>
|
||||||
<x:String x:Key="Text.Configure.IssueTracker.RuleName" xml:space="preserve">規則名稱:</x:String>
|
<x:String x:Key="Text.Configure.IssueTracker.RuleName" xml:space="preserve">規則名稱:</x:String>
|
||||||
|
|
|
@ -172,6 +172,34 @@ namespace SourceGit.ViewModels
|
||||||
SelectedIssueTrackerRule = _repo.Settings.AddJiraIssueTracker();
|
SelectedIssueTrackerRule = _repo.Settings.AddJiraIssueTracker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddSampleGitLabIssueTracker()
|
||||||
|
{
|
||||||
|
foreach (var remote in _repo.Remotes)
|
||||||
|
{
|
||||||
|
if (remote.TryGetVisitURL(out string url))
|
||||||
|
{
|
||||||
|
SelectedIssueTrackerRule = _repo.Settings.AddGitLabIssueTracker(url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedIssueTrackerRule = _repo.Settings.AddGitLabIssueTracker(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddSampleGitLabMergeRequestTracker()
|
||||||
|
{
|
||||||
|
foreach (var remote in _repo.Remotes)
|
||||||
|
{
|
||||||
|
if (remote.TryGetVisitURL(out string url))
|
||||||
|
{
|
||||||
|
SelectedIssueTrackerRule = _repo.Settings.AddGitLabMergeRequestTracker(url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedIssueTrackerRule = _repo.Settings.AddGitLabMergeRequestTracker(null);
|
||||||
|
}
|
||||||
|
|
||||||
public void NewIssueTracker()
|
public void NewIssueTracker()
|
||||||
{
|
{
|
||||||
SelectedIssueTrackerRule = _repo.Settings.AddNewIssueTracker();
|
SelectedIssueTrackerRule = _repo.Settings.AddNewIssueTracker();
|
||||||
|
|
|
@ -287,6 +287,8 @@
|
||||||
<MenuItem Header="-"/>
|
<MenuItem Header="-"/>
|
||||||
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGithub}" Command="{Binding AddSampleGithubIssueTracker}"/>
|
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGithub}" Command="{Binding AddSampleGithubIssueTracker}"/>
|
||||||
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleJira}" Command="{Binding AddSampleJiraIssueTracker}"/>
|
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleJira}" Command="{Binding AddSampleJiraIssueTracker}"/>
|
||||||
|
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGitLabIssue}" Command="{Binding AddSampleGitLabIssueTracker}"/>
|
||||||
|
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGitLabMergeRequest}" Command="{Binding AddSampleGitLabMergeRequestTracker}"/>
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
</Button.Flyout>
|
</Button.Flyout>
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
||||||
|
|
Loading…
Reference in a new issue