2015-09-25 12:07:36 +05:30
|
|
|
require 'gitlab/markdown'
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
module Gitlab
|
|
|
|
module Markdown
|
|
|
|
# Common methods for ReferenceFilters that support an optional cross-project
|
|
|
|
# reference.
|
|
|
|
module CrossProjectReference
|
|
|
|
# Given a cross-project reference string, get the Project record
|
|
|
|
#
|
|
|
|
# Defaults to value of `context[:project]` if:
|
|
|
|
# * No reference is given OR
|
|
|
|
# * Reference given doesn't exist
|
|
|
|
#
|
|
|
|
# ref - String reference.
|
|
|
|
#
|
2015-10-24 18:46:33 +05:30
|
|
|
# Returns a Project, or nil if the reference can't be found
|
2015-09-11 14:41:01 +05:30
|
|
|
def project_from_ref(ref)
|
|
|
|
return context[:project] unless ref
|
|
|
|
|
2015-10-24 18:46:33 +05:30
|
|
|
Project.find_with_namespace(ref)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|