Skip to content
Snippets Groups Projects
Commit 48daab5f authored by Kamil Trzcińśki's avatar Kamil Trzcińśki
Browse files

Use repository and redis cache

parent 3c508eaa
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -51,7 +51,7 @@ class Projects::IssuesController < Projects::ApplicationController
 
@issue = @noteable = @project.issues.new(issue_params)
 
@issue.description = @project.repository_issues_template
@issue.description = @project.repository.issues_template
 
respond_with(@issue)
end
Loading
Loading
Loading
Loading
@@ -929,16 +929,4 @@ class Project < ActiveRecord::Base
def wiki
@wiki ||= ProjectWiki.new(self, self.owner)
end
def repository_issues_template
repository.blob_at_branch('HEAD', 'ISSUE_TEMPLATE').data
rescue
nil
end
def repository_merge_requests_template
repository.blob_at_branch('HEAD', 'MERGE_REQUESTS_TEMPLATE').data
rescue
nil
end
end
Loading
Loading
@@ -375,6 +375,26 @@ class Repository
end
end
 
def issue_template
cache.fetch(:issue_template) do
[nil, '.gitlab', '.github'].each do |path|
tree(:head, path).blobs.find do |file|
file.name =~ /\Aissue_template(?\.txt)(?\.md)\z/i
end
end
end
end
def merge_request_template
cache.fetch(:merge_request_template) do
[nil, '.gitlab', '.github'].each do |path|
tree(:head, path).blobs.find do |file|
file.name =~ /\Amerge_request_template(?\.txt)(?\.md)\z/i
end
end
end
end
def head_commit
@head_commit ||= commit(self.root_ref)
end
Loading
Loading
Loading
Loading
@@ -61,7 +61,7 @@ module MergeRequests
merge_request.title = merge_request.source_branch.titleize.humanize
end
 
merge_request.description = merge_request.target_project.repository_merge_requests_template
merge_request.description = merge_request.target_project.repository.merge_request_template
 
merge_request
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment