diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs index 74c07418..40c00bc9 100644 --- a/src/Models/RepositorySettings.cs +++ b/src/Models/RepositorySettings.cs @@ -169,6 +169,32 @@ namespace SourceGit.Models 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) { if (rule != null) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 93b3febf..2726aec2 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -147,6 +147,8 @@ ISSUE TRACKER Add Sample Github Rule Add Sample Jira Rule + Add Sample GitLab Issue Rule + Add Sample GitLab Merge Request 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 6938ffce..d99091c2 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -150,6 +150,8 @@ ISSUE追踪 新增匹配Github Issue规则 新增匹配Jira规则 + 新增匹配GitLab议题规则 + 新增匹配GitLab合并请求规则 新增自定义规则 匹配ISSUE的正则表达式 : 规则名 : diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index f1612150..44f74dfc 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -150,6 +150,8 @@ Issue 追蹤 新增符合 GitHub Issue 規則 新增符合 Jira 規則 + 新增符合 GitLab 議題規則 + 新增符合 GitLab 合併請求規則 新增自訂規則 符合 Issue 的正則表達式: 規則名稱: diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs index 8b724383..3c969c4d 100644 --- a/src/ViewModels/RepositoryConfigure.cs +++ b/src/ViewModels/RepositoryConfigure.cs @@ -172,6 +172,34 @@ namespace SourceGit.ViewModels 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() { SelectedIssueTrackerRule = _repo.Settings.AddNewIssueTracker(); diff --git a/src/Views/RepositoryConfigure.axaml b/src/Views/RepositoryConfigure.axaml index 706fa2ef..6383d904 100644 --- a/src/Views/RepositoryConfigure.axaml +++ b/src/Views/RepositoryConfigure.axaml @@ -287,6 +287,8 @@ + +