Commit 3301876b authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'allow_single_letter_external_issue_ids' into 'master'

Allow single letter external issue IDs

Closes #52803

See merge request gitlab-org/gitlab-ce!22717
parents ea3b8864 9de175bf
...@@ -12,9 +12,9 @@ class IssueTrackerService < Service ...@@ -12,9 +12,9 @@ class IssueTrackerService < Service
# overridden patterns. See ReferenceRegexes::EXTERNAL_PATTERN # overridden patterns. See ReferenceRegexes::EXTERNAL_PATTERN
def self.reference_pattern(only_long: false) def self.reference_pattern(only_long: false)
if only_long if only_long
/(\b[A-Z][A-Z0-9_]+-)(?<issue>\d+)/ /(\b[A-Z][A-Z0-9_]*-)(?<issue>\d+)/
else else
/(\b[A-Z][A-Z0-9_]+-|#{Issue.reference_prefix})(?<issue>\d+)/ /(\b[A-Z][A-Z0-9_]*-|#{Issue.reference_prefix})(?<issue>\d+)/
end end
end end
......
---
title: "Allowing issues with single letter identifiers to be linked to external issue tracker (f.ex T-123)"
merge_request: 22717
author: Dídac Rodríguez Arbonès
type: changed
\ No newline at end of file
...@@ -101,16 +101,25 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do ...@@ -101,16 +101,25 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do
context "redmine project" do context "redmine project" do
let(:project) { create(:redmine_project) } let(:project) { create(:redmine_project) }
before do
project.update!(issues_enabled: false)
end
context "with a hash prefix" do
let(:issue) { ExternalIssue.new("#123", project) } let(:issue) { ExternalIssue.new("#123", project) }
let(:reference) { issue.to_reference } let(:reference) { issue.to_reference }
before do it_behaves_like "external issue tracker"
project.issues_enabled = false
project.save!
end end
context "with a single-letter prefix" do
let(:issue) { ExternalIssue.new("T-123", project) }
let(:reference) { issue.to_reference }
it_behaves_like "external issue tracker" it_behaves_like "external issue tracker"
end end
end
context "jira project" do context "jira project" do
let(:project) { create(:jira_project) } let(:project) { create(:jira_project) }
...@@ -122,6 +131,15 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do ...@@ -122,6 +131,15 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do
it_behaves_like "external issue tracker" it_behaves_like "external issue tracker"
end end
context "with a single-letter prefix" do
let(:issue) { ExternalIssue.new("J-123", project) }
it "ignores reference" do
exp = act = "Issue #{reference}"
expect(filter(act).to_html).to eq exp
end
end
context "with wrong markdown" do context "with wrong markdown" do
let(:issue) { ExternalIssue.new("#123", project) } let(:issue) { ExternalIssue.new("#123", project) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment