summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-04-17 12:34:51 +0200
committerRobert Speicher <rspeicher@gmail.com>2015-04-20 13:01:47 -0400
commitb5802d144b4141b2259247f83903f3431ed6199c (patch)
tree5ebe0c9c82529c2dda1efcdbaca0354b1f6b5096 /lib
parentb595249462346d48817330baf8c253b6f08690a1 (diff)
downloadgitlab-ce-b5802d144b4141b2259247f83903f3431ed6199c.tar.gz
project_from_ref returns nil when reference doesn't exist.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/markdown/cross_project_reference.rb15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/gitlab/markdown/cross_project_reference.rb b/lib/gitlab/markdown/cross_project_reference.rb
index de05102751f..887c205cdc9 100644
--- a/lib/gitlab/markdown/cross_project_reference.rb
+++ b/lib/gitlab/markdown/cross_project_reference.rb
@@ -16,15 +16,12 @@ module Gitlab
#
# Returns a Project, or nil if the reference can't be accessed
def project_from_ref(ref)
- if ref && other = Project.find_with_namespace(ref)
- if user_can_reference_project?(other)
- other
- else
- nil
- end
- else
- context[:project]
- end
+ return context[:project] unless ref
+
+ other = Project.find_with_namespace(ref)
+ return nil unless other && user_can_reference_project?(other)
+
+ other
end
def user_can_reference_project?(project, user = context[:current_user])