Commit d33a2258 authored by Nick Thomas's avatar Nick Thomas

Use title, not full_title for commit mentionables

Currently, the first line of a commit message is processed twice by
Commit#all_references, which can be a performance issue if it is very
long. In those cases, `title` returns the first 100 characters of the
line while `description` contains the full line, so this minimises the
amount of text that must be processed.

In cases with a short title and more lines after, i.e., well-formed
commit messages, the first line does not appear in the description, so
we do need both `attr_mentionable`s for references to be scanned.

Changelog: performance
parent 05cb919c
......@@ -38,7 +38,7 @@ class Commit
cache_markdown_field :description, pipeline: :commit_description, limit: 1.megabyte
# Share the cache used by the markdown fields
attr_mentionable :full_title, pipeline: :single_line, limit: 1.kilobyte
attr_mentionable :title, pipeline: :single_line
attr_mentionable :description, pipeline: :commit_description, limit: 1.megabyte
class << self
......
......@@ -841,7 +841,7 @@ RSpec.describe Issuable do
it_behaves_like 'matches_cross_reference_regex? fails fast'
end
context "note with long path string", quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/35269' do
context "note with long path string" do
let(:project) { create(:project, :public, :repository) }
let(:mentionable) { project.commit }
......
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