mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-11 23:57:21 -08:00
feature: add issue/pr tracker for Gitee.com (#884)
This commit is contained in:
parent
9baa2c9fad
commit
22ba8b3acf
6 changed files with 71 additions and 3 deletions
|
@ -521,6 +521,32 @@ namespace SourceGit.Models
|
|||
return rule;
|
||||
}
|
||||
|
||||
public IssueTrackerRule AddGiteeIssueTracker(string repoURL)
|
||||
{
|
||||
var rule = new IssueTrackerRule()
|
||||
{
|
||||
Name = "Gitee ISSUE",
|
||||
RegexString = "#([0-9A-Z]{6,10})",
|
||||
URLTemplate = string.IsNullOrEmpty(repoURL) ? "https://gitee.com/username/repository/issues/$1" : $"{repoURL}/issues/$1",
|
||||
};
|
||||
|
||||
IssueTrackerRules.Add(rule);
|
||||
return rule;
|
||||
}
|
||||
|
||||
public IssueTrackerRule AddGiteePullRequestTracker(string repoURL)
|
||||
{
|
||||
var rule = new IssueTrackerRule()
|
||||
{
|
||||
Name = "Gitee Pull Request",
|
||||
RegexString = "!(\\d+)",
|
||||
URLTemplate = string.IsNullOrEmpty(repoURL) ? "https://gitee.com/username/repository/pulls/$1" : $"{repoURL}/pulls/$1",
|
||||
};
|
||||
|
||||
IssueTrackerRules.Add(rule);
|
||||
return rule;
|
||||
}
|
||||
|
||||
public void RemoveIssueTracker(IssueTrackerRule rule)
|
||||
{
|
||||
if (rule != null)
|
||||
|
|
|
@ -161,10 +161,12 @@
|
|||
<x:String x:Key="Text.Configure.Git.EnablePruneOnFetch" xml:space="preserve">Enable --prune on fetch</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.EnableSignOff" xml:space="preserve">Enable --signoff for commit</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE TRACKER</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteeIssue" xml:space="preserve">Add Sample Gitee Issue Rule</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteePullRequest" xml:space="preserve">Add Sample Gitee Pull Request 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.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.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>
|
||||
<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>
|
||||
|
|
|
@ -164,10 +164,12 @@
|
|||
<x:String x:Key="Text.Configure.Git.EnableSignOff" xml:space="preserve">提交信息追加署名 (--signoff)</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.EnablePruneOnFetch" xml:space="preserve">拉取更新时启用修剪(--prune)</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE追踪</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteeIssue" xml:space="preserve">新增匹配Gitee议题规则</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteePullRequest" xml:space="preserve">新增匹配Gitee合并请求规则</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.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.AddSampleJira" xml:space="preserve">新增匹配Jira规则</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.RuleName" xml:space="preserve">规则名 :</x:String>
|
||||
|
|
|
@ -164,10 +164,12 @@
|
|||
<x:String x:Key="Text.Configure.Git.EnableSignOff" xml:space="preserve">提交訊息追加署名 (--signoff)</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.EnablePruneOnFetch" xml:space="preserve">拉取變更時進行清理 (--prune)</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">Issue 追蹤</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteeIssue" xml:space="preserve">新增符合 Gitee 議題規則</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGiteePullRequest" xml:space="preserve">新增符合 Gitee 合併請求規則</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.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.AddSampleJira" xml:space="preserve">新增符合 Jira 規則</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.RuleName" xml:space="preserve">規則名稱:</x:String>
|
||||
|
|
|
@ -236,6 +236,40 @@ namespace SourceGit.ViewModels
|
|||
SelectedIssueTrackerRule = _repo.Settings.AddGitLabMergeRequestTracker(null);
|
||||
}
|
||||
|
||||
public void AddSampleGiteeIssueTracker()
|
||||
{
|
||||
foreach (var remote in _repo.Remotes)
|
||||
{
|
||||
if (remote.URL.Contains("gitee.com", System.StringComparison.Ordinal))
|
||||
{
|
||||
if (remote.TryGetVisitURL(out string url))
|
||||
{
|
||||
SelectedIssueTrackerRule = _repo.Settings.AddGiteeIssueTracker(url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SelectedIssueTrackerRule = _repo.Settings.AddGiteeIssueTracker(null);
|
||||
}
|
||||
|
||||
public void AddSampleGiteePullRequestTracker()
|
||||
{
|
||||
foreach (var remote in _repo.Remotes)
|
||||
{
|
||||
if (remote.URL.Contains("gitee.com", System.StringComparison.Ordinal))
|
||||
{
|
||||
if (remote.TryGetVisitURL(out string url))
|
||||
{
|
||||
SelectedIssueTrackerRule = _repo.Settings.AddGiteePullRequestTracker(url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SelectedIssueTrackerRule = _repo.Settings.AddGiteePullRequestTracker(null);
|
||||
}
|
||||
|
||||
public void NewIssueTracker()
|
||||
{
|
||||
SelectedIssueTrackerRule = _repo.Settings.AddNewIssueTracker();
|
||||
|
|
|
@ -290,6 +290,8 @@
|
|||
<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}"/>
|
||||
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGiteeIssue}" Command="{Binding AddSampleGiteeIssueTracker}"/>
|
||||
<MenuItem Header="{DynamicResource Text.Configure.IssueTracker.AddSampleGiteePullRequest}" Command="{Binding AddSampleGiteePullRequestTracker}"/>
|
||||
</MenuFlyout>
|
||||
</Button.Flyout>
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
||||
|
|
Loading…
Reference in a new issue