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
# overridden patterns. See ReferenceRegexes::EXTERNAL_PATTERN
def self.reference_pattern(only_long: false)
if only_long
/(\b[A-Z][A-Z0-9_]+-)(?<issue>\d+)/
/(\b[A-Z][A-Z0-9_]*-)(?<issue>\d+)/
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
......
---
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,15 +101,24 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do
context "redmine project" do
let(:project) { create(:redmine_project) }
let(:issue) { ExternalIssue.new("#123", project) }
let(:reference) { issue.to_reference }
before do
project.issues_enabled = false
project.save!
project.update!(issues_enabled: false)
end
context "with a hash prefix" do
let(:issue) { ExternalIssue.new("#123", project) }
let(:reference) { issue.to_reference }
it_behaves_like "external issue tracker"
end
it_behaves_like "external issue tracker"
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"
end
end
context "jira project" do
......@@ -122,6 +131,15 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do
it_behaves_like "external issue tracker"
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
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