diff options
author | Robert Speicher <robert@gitlab.com> | 2016-08-09 21:45:59 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-08-09 21:45:59 +0000 |
commit | bd1b8ae9bbbe8c81d5f1c18a5c8d86fbcb4f1dbf (patch) | |
tree | b6d8aaaf718650ac0be6cf7ef059a80465a75ed4 /lib/banzai | |
parent | 936729e5be97d88fbc927ede20ec1d4cf5fe6daa (diff) | |
parent | e63eccf9744de0965d4727326a4b30f1fe8165e8 (diff) | |
download | gitlab-ce-bd1b8ae9bbbe8c81d5f1c18a5c8d86fbcb4f1dbf.tar.gz |
Merge branch 'relative-link-filter-ref' into 'master'
Do not look up commit again when it is passed to RelativeLinkFilter
## What does this MR do?
Use `context[:commit]` in RelativeLinkFilter instead of looking up commit using `context[:ref]`.
## Why was this MR needed?
Even though the commit object was already passed, unnecessary I/O is done to retrieve the commit object.
## What are the relevant issue numbers?
Fixes #20026
See merge request !5455
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/relative_link_filter.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb index 46762d401fb..4fa8d05481f 100644 --- a/lib/banzai/filter/relative_link_filter.rb +++ b/lib/banzai/filter/relative_link_filter.rb @@ -52,7 +52,7 @@ module Banzai relative_url_root, context[:project].path_with_namespace, uri_type(file_path), - ref || context[:project].default_branch, # if no ref exists, point to the default branch + ref, file_path ].compact.join('/').squeeze('/').chomp('/') @@ -116,7 +116,7 @@ module Banzai end def current_commit - @current_commit ||= context[:commit] || ref ? repository.commit(ref) : repository.head_commit + @current_commit ||= context[:commit] || repository.commit(ref) end def relative_url_root @@ -124,7 +124,7 @@ module Banzai end def ref - context[:ref] + context[:ref] || context[:project].default_branch end def repository |