mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-13 14:46:05 +10:00
Commit ranges, commits, external issues, issues, labels, merge requests, snippets, users.
27 lines
747 B
Ruby
27 lines
747 B
Ruby
module Gitlab
|
|
module Markdown
|
|
# Includes shared code for reference filters that support an optional
|
|
# cross-project reference.
|
|
module CrossProjectReference
|
|
NAMING_PATTERN = Gitlab::Regex::NAMESPACE_REGEX_STR
|
|
PROJECT_PATTERN = "(?<project>#{NAMING_PATTERN}/#{NAMING_PATTERN})"
|
|
|
|
# Given a cross-project reference string, get the Project record
|
|
#
|
|
# If no valid reference is given, returns the `:project` value for the
|
|
# current context.
|
|
#
|
|
# ref - String reference.
|
|
#
|
|
# Returns a Project
|
|
def project_from_ref(ref)
|
|
if ref && other = Project.find_with_namespace(ref)
|
|
other
|
|
else
|
|
context[:project]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|