diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-07 16:10:53 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-12-07 16:10:53 +0100 |
commit | ad19de19498a1337a242fd67731e59771e65a9d3 (patch) | |
tree | c94ae4edbc65748118f6a32b26b52e5abc9f7dbe /lib/banzai/filter/abstract_reference_filter.rb | |
parent | f55fcef3dbadf5f3003e0a51633e30e05b47c51d (diff) | |
parent | e09c6df0682c499e221a0da41ac263482fbcf568 (diff) | |
download | gitlab-ce-ad19de19498a1337a242fd67731e59771e65a9d3.tar.gz |
Merge branch 'master' into auto-pipelines-vue
* master: (114 commits)
Remove dashboard.scss
Update custom_hooks.md for global custom hooks and chained hook info
Move admin hooks spinach to rspec
Move admin logs spinach test to rspec
Fix 404 error when visit group label edit page
A simpler implementation of finding a merge request
Encourage bug reporters to mention if they use GitLab.com
Bump gitlab-shell version to 4.0.3
Remove confirmation.scss
Explain "js: true" in "deleted_source_branch_spec.rb"
Move award emojis to framwork
Move image styles to framework
Remove tags.scss
Remove caching of Repository#has_visible_content?
Add text example for pipeline status without action
Use detailed status as CSS class in pipelines list
Use status text when redering pipelines list
Improve support for icons in new detailed statuses
Add status label information to pipeline header
Untangle status label and text in ci status helper
...
Diffstat (limited to 'lib/banzai/filter/abstract_reference_filter.rb')
-rw-r--r-- | lib/banzai/filter/abstract_reference_filter.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/banzai/filter/abstract_reference_filter.rb b/lib/banzai/filter/abstract_reference_filter.rb index 3740d4fb4cd..d904a8bd4ae 100644 --- a/lib/banzai/filter/abstract_reference_filter.rb +++ b/lib/banzai/filter/abstract_reference_filter.rb @@ -33,7 +33,7 @@ module Banzai # Returns a String replaced with the return of the block. def self.references_in(text, pattern = object_class.reference_pattern) text.gsub(pattern) do |match| - yield match, $~[object_sym].to_i, $~[:project], $~ + yield match, $~[object_sym].to_i, $~[:project], $~[:namespace], $~ end end @@ -145,8 +145,9 @@ module Banzai # Returns a String with references replaced with links. All links # have `gfm` and `gfm-OBJECT_NAME` class names attached for styling. def object_link_filter(text, pattern, link_content: nil) - references_in(text, pattern) do |match, id, project_ref, matches| - project = project_from_ref_cached(project_ref) + references_in(text, pattern) do |match, id, project_ref, namespace_ref, matches| + project_path = full_project_path(namespace_ref, project_ref) + project = project_from_ref_cached(project_path) if project && object = find_object_cached(project, id) title = object_link_title(object) @@ -217,10 +218,9 @@ module Banzai nodes.each do |node| node.to_html.scan(regex) do - project = $~[:project] || current_project_path + project_path = full_project_path($~[:namespace], $~[:project]) symbol = $~[object_sym] - - refs[project] << symbol if object_class.reference_valid?(symbol) + refs[project_path] << symbol if object_class.reference_valid?(symbol) end end @@ -272,8 +272,19 @@ module Banzai @current_project_path ||= project.path_with_namespace end + def current_project_namespace_path + @current_project_namespace_path ||= project.namespace.path + end + private + def full_project_path(namespace, project_ref) + return current_project_path unless project_ref + + namespace_ref = namespace || current_project_namespace_path + "#{namespace_ref}/#{project_ref}" + end + def project_refs_cache RequestStore[:banzai_project_refs] ||= {} end |