Merge branch 'improve-project-lookup' into 'master'
Improve Project Lookup Fixes #1080
This commit is contained in:
commit
66a484c9cd
2 changed files with 7 additions and 9 deletions
|
@ -177,15 +177,13 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def find_with_namespace(id)
|
||||
if id.include?("/")
|
||||
return nil unless id.include?("/")
|
||||
|
||||
id = id.split("/")
|
||||
namespace = Namespace.find_by(path: id.first)
|
||||
return nil unless namespace
|
||||
|
||||
where(namespace_id: namespace.id).find_by(path: id.second)
|
||||
else
|
||||
where(path: id, namespace_id: nil).last
|
||||
end
|
||||
end
|
||||
|
||||
def visibility_levels
|
||||
|
|
|
@ -47,7 +47,7 @@ module API
|
|||
end
|
||||
|
||||
def find_project(id)
|
||||
project = Project.find_by(id: id) || Project.find_with_namespace(id)
|
||||
project = Project.find_with_namespace(id) || Project.find_by(id: id)
|
||||
|
||||
if project && can?(current_user, :read_project, project)
|
||||
project
|
||||
|
|
Loading…
Reference in a new issue