diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-20 10:52:01 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-20 10:52:01 +0100 |
commit | 6eb31056346ed07db4f66e4ba2369ff9779230c5 (patch) | |
tree | 073c60878f25ea26b8b5b61c6820434cb0f45a70 /lib | |
parent | 323d328c8644e3ff01b806f7754d33c0c7dedd7b (diff) | |
download | gitlab-ce-6eb31056346ed07db4f66e4ba2369ff9779230c5.tar.gz |
Find referable for each ref found in references rewriter
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/gfm/reference_rewriter.rb | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/gitlab/gfm/reference_rewriter.rb b/lib/gitlab/gfm/reference_rewriter.rb index 91069732d44..edc96a5e83b 100644 --- a/lib/gitlab/gfm/reference_rewriter.rb +++ b/lib/gitlab/gfm/reference_rewriter.rb @@ -49,7 +49,7 @@ module Gitlab def unfold_reference(reference, match, target_project) before = @text[0...match.begin(0)] after = @text[match.end(0)..-1] - referable = find_local_referable(reference) + referable = find_referable(reference) return reference unless referable cross_reference = referable.to_reference(target_project) @@ -58,17 +58,11 @@ module Gitlab substitution_valid?(new_text) ? cross_reference : reference end - def referables - return @referables if @referables - + def find_referable(reference) extractor = Gitlab::ReferenceExtractor.new(@source_project, @current_user) - extractor.analyze(@text) - @referables = extractor.all - end - - def find_local_referable(reference) - referables.find { |ref| ref.to_reference == reference } + extractor.analyze(reference) + extractor.all.first end def substitution_valid?(substituted) |