Welcome to mirror list, hosted at ThFree Co, Russian Federation.

merge_request_template.rb « template « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7491c8f26c61a109105f1aac7fb392b43ab03630 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

module Gitlab
  module Template
    class MergeRequestTemplate < BaseTemplate
      class << self
        def extension
          '.md'
        end

        def base_dir
          '.gitlab/merge_request_templates/'
        end

        def finder(project)
          Gitlab::Template::Finders::RepoTemplateFinder.new(project, self.base_dir, self.extension, self.categories)
        end

        def template_names(project)
          return {} unless project&.repository&.exists?

          # here we rely on project.repository caching mechanism. Ideally we would want the template finder to have its
          # own caching mechanism to avoid the back and forth call jumps between finder and model.
          #
          # follow-up issue: https://gitlab.com/gitlab-org/gitlab/-/issues/300279
          project.repository.merge_request_template_names_hash
        end
      end
    end
  end
end