diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index f63a19fc..e10e9760 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -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) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 0a81617a..cc32cc4a 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -161,10 +161,12 @@ Enable --prune on fetch Enable --signoff for commit ISSUE TRACKER + Add Sample Gitee Issue Rule + Add Sample Gitee Pull Request Rule Add Sample Github Rule - Add Sample Jira Rule Add Sample GitLab Issue Rule Add Sample GitLab Merge Request Rule + Add Sample Jira Rule New Rule Issue Regex Expression: Rule Name: diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index cc765738..c7dede50 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -164,10 +164,12 @@ 提交信息追加署名 (--signoff) 拉取更新时启用修剪(--prune) ISSUE追踪 + 新增匹配Gitee议题规则 + 新增匹配Gitee合并请求规则 新增匹配Github Issue规则 - 新增匹配Jira规则 新增匹配GitLab议题规则 新增匹配GitLab合并请求规则 + 新增匹配Jira规则 新增自定义规则 匹配ISSUE的正则表达式 : 规则名 : diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index 758ec3be..429febeb 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -164,10 +164,12 @@ 提交訊息追加署名 (--signoff) 拉取變更時進行清理 (--prune) Issue 追蹤 + 新增符合 Gitee 議題規則 + 新增符合 Gitee 合併請求規則 新增符合 GitHub Issue 規則 - 新增符合 Jira 規則 新增符合 GitLab 議題規則 新增符合 GitLab 合併請求規則 + 新增符合 Jira 規則 新增自訂規則 符合 Issue 的正規表達式: 規則名稱: diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs index 95fb5517..fb8cbfdb 100644 --- a/src/ViewModels/RepositoryConfigure.cs +++ b/src/ViewModels/RepositoryConfigure.cs @@ -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(); diff --git a/src/Views/RepositoryConfigure.axaml b/src/Views/RepositoryConfigure.axaml index a5772e61..5c1ce989 100644 --- a/src/Views/RepositoryConfigure.axaml +++ b/src/Views/RepositoryConfigure.axaml @@ -290,6 +290,8 @@ + +