Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
a0586dbc
Commit
a0586dbc
authored
Feb 03, 2017
by
Adam Pahlevi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace `find_with_namespace` with `find_by_full_path`
add complete changelog for !8949
parent
d777e6f1
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
32 additions
and
32 deletions
+32
-32
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+1
-1
app/controllers/admin/runner_projects_controller.rb
app/controllers/admin/runner_projects_controller.rb
+1
-1
app/controllers/projects/application_controller.rb
app/controllers/projects/application_controller.rb
+1
-1
app/controllers/projects/git_http_client_controller.rb
app/controllers/projects/git_http_client_controller.rb
+1
-1
app/controllers/projects/uploads_controller.rb
app/controllers/projects/uploads_controller.rb
+1
-1
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+1
-1
app/models/project.rb
app/models/project.rb
+1
-5
app/services/auth/container_registry_authentication_service.rb
...ervices/auth/container_registry_authentication_service.rb
+1
-1
changelogs/unreleased/fwn-to-find-by-full-path.yml
changelogs/unreleased/fwn-to-find-by-full-path.yml
+4
-0
db/fixtures/development/10_merge_requests.rb
db/fixtures/development/10_merge_requests.rb
+1
-1
lib/api/helpers.rb
lib/api/helpers.rb
+1
-1
lib/api/helpers/internal_helpers.rb
lib/api/helpers/internal_helpers.rb
+2
-2
lib/banzai/cross_project_reference.rb
lib/banzai/cross_project_reference.rb
+1
-1
lib/constraints/project_url_constrainer.rb
lib/constraints/project_url_constrainer.rb
+1
-1
lib/gitlab/email/handler/create_issue_handler.rb
lib/gitlab/email/handler/create_issue_handler.rb
+1
-1
lib/gitlab/git_post_receive.rb
lib/gitlab/git_post_receive.rb
+2
-2
lib/tasks/gitlab/cleanup.rake
lib/tasks/gitlab/cleanup.rake
+1
-1
lib/tasks/gitlab/import.rake
lib/tasks/gitlab/import.rake
+1
-1
lib/tasks/gitlab/sidekiq.rake
lib/tasks/gitlab/sidekiq.rake
+1
-1
spec/lib/banzai/cross_project_reference_spec.rb
spec/lib/banzai/cross_project_reference_spec.rb
+1
-1
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+4
-4
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+3
-3
No files found.
app/controllers/admin/projects_controller.rb
View file @
a0586dbc
...
@@ -45,7 +45,7 @@ class Admin::ProjectsController < Admin::ApplicationController
...
@@ -45,7 +45,7 @@ class Admin::ProjectsController < Admin::ApplicationController
protected
protected
def
project
def
project
@project
=
Project
.
find_
with_namespace
(
@project
=
Project
.
find_
by_full_path
(
[
params
[
:namespace_id
],
'/'
,
params
[
:id
]].
join
(
''
)
[
params
[
:namespace_id
],
'/'
,
params
[
:id
]].
join
(
''
)
)
)
@project
||
render_404
@project
||
render_404
...
...
app/controllers/admin/runner_projects_controller.rb
View file @
a0586dbc
...
@@ -24,7 +24,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
...
@@ -24,7 +24,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
private
private
def
project
def
project
@project
=
Project
.
find_
with_namespace
(
@project
=
Project
.
find_
by_full_path
(
[
params
[
:namespace_id
],
'/'
,
params
[
:project_id
]].
join
(
''
)
[
params
[
:namespace_id
],
'/'
,
params
[
:project_id
]].
join
(
''
)
)
)
@project
||
render_404
@project
||
render_404
...
...
app/controllers/projects/application_controller.rb
View file @
a0586dbc
...
@@ -24,7 +24,7 @@ class Projects::ApplicationController < ApplicationController
...
@@ -24,7 +24,7 @@ class Projects::ApplicationController < ApplicationController
end
end
project_path
=
"
#{
namespace
}
/
#{
id
}
"
project_path
=
"
#{
namespace
}
/
#{
id
}
"
@project
=
Project
.
find_
with_namespace
(
project_path
)
@project
=
Project
.
find_
by_full_path
(
project_path
)
if
can?
(
current_user
,
:read_project
,
@project
)
&&
!
@project
.
pending_delete?
if
can?
(
current_user
,
:read_project
,
@project
)
&&
!
@project
.
pending_delete?
if
@project
.
path_with_namespace
!=
project_path
if
@project
.
path_with_namespace
!=
project_path
...
...
app/controllers/projects/git_http_client_controller.rb
View file @
a0586dbc
...
@@ -79,7 +79,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController
...
@@ -79,7 +79,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController
if
project_id
.
blank?
if
project_id
.
blank?
@project
=
nil
@project
=
nil
else
else
@project
=
Project
.
find_
with_namespace
(
"
#{
params
[
:namespace_id
]
}
/
#{
project_id
}
"
)
@project
=
Project
.
find_
by_full_path
(
"
#{
params
[
:namespace_id
]
}
/
#{
project_id
}
"
)
end
end
end
end
...
...
app/controllers/projects/uploads_controller.rb
View file @
a0586dbc
...
@@ -36,7 +36,7 @@ class Projects::UploadsController < Projects::ApplicationController
...
@@ -36,7 +36,7 @@ class Projects::UploadsController < Projects::ApplicationController
namespace
=
params
[
:namespace_id
]
namespace
=
params
[
:namespace_id
]
id
=
params
[
:project_id
]
id
=
params
[
:project_id
]
file_project
=
Project
.
find_
with_namespace
(
"
#{
namespace
}
/
#{
id
}
"
)
file_project
=
Project
.
find_
by_full_path
(
"
#{
namespace
}
/
#{
id
}
"
)
if
file_project
.
nil?
if
file_project
.
nil?
@uploader
=
nil
@uploader
=
nil
...
...
app/helpers/application_helper.rb
View file @
a0586dbc
...
@@ -37,7 +37,7 @@ module ApplicationHelper
...
@@ -37,7 +37,7 @@ module ApplicationHelper
if
project_id
.
is_a?
(
Project
)
if
project_id
.
is_a?
(
Project
)
project_id
project_id
else
else
Project
.
find_
with_namespace
(
project_id
)
Project
.
find_
by_full_path
(
project_id
)
end
end
if
project
.
avatar_url
if
project
.
avatar_url
...
...
app/models/project.rb
View file @
a0586dbc
...
@@ -369,10 +369,6 @@ class Project < ActiveRecord::Base
...
@@ -369,10 +369,6 @@ class Project < ActiveRecord::Base
def
group_ids
def
group_ids
joins
(
:namespace
).
where
(
namespaces:
{
type:
'Group'
}).
select
(
:namespace_id
)
joins
(
:namespace
).
where
(
namespaces:
{
type:
'Group'
}).
select
(
:namespace_id
)
end
end
# Add alias for Routable method for compatibility with old code.
# In future all calls `find_with_namespace` should be replaced with `find_by_full_path`
alias_method
:find_with_namespace
,
:find_by_full_path
end
end
def
lfs_enabled?
def
lfs_enabled?
...
@@ -1345,6 +1341,6 @@ class Project < ActiveRecord::Base
...
@@ -1345,6 +1341,6 @@ class Project < ActiveRecord::Base
def
pending_delete_twin
def
pending_delete_twin
return
false
unless
path
return
false
unless
path
Project
.
unscoped
.
where
(
pending_delete:
true
).
find_
with_namespace
(
path_with_namespace
)
Project
.
unscoped
.
where
(
pending_delete:
true
).
find_
by_full_path
(
path_with_namespace
)
end
end
end
end
app/services/auth/container_registry_authentication_service.rb
View file @
a0586dbc
...
@@ -61,7 +61,7 @@ module Auth
...
@@ -61,7 +61,7 @@ module Auth
end
end
def
process_repository_access
(
type
,
name
,
actions
)
def
process_repository_access
(
type
,
name
,
actions
)
requested_project
=
Project
.
find_
with_namespace
(
name
)
requested_project
=
Project
.
find_
by_full_path
(
name
)
return
unless
requested_project
return
unless
requested_project
actions
=
actions
.
select
do
|
action
|
actions
=
actions
.
select
do
|
action
|
...
...
changelogs/unreleased/fwn-to-find-by-full-path.yml
0 → 100644
View file @
a0586dbc
---
title
:
replace `find_with_namespace` with `find_by_full_path`
merge_request
:
8949
author
:
Adam Pahlevi
db/fixtures/development/10_merge_requests.rb
View file @
a0586dbc
...
@@ -26,7 +26,7 @@ Gitlab::Seeder.quiet do
...
@@ -26,7 +26,7 @@ Gitlab::Seeder.quiet do
end
end
end
end
project
=
Project
.
find_
with_namespace
(
'gitlab-org/gitlab-test'
)
project
=
Project
.
find_
by_full_path
(
'gitlab-org/gitlab-test'
)
params
=
{
params
=
{
source_branch:
'feature'
,
source_branch:
'feature'
,
...
...
lib/api/helpers.rb
View file @
a0586dbc
...
@@ -45,7 +45,7 @@ module API
...
@@ -45,7 +45,7 @@ module API
if
id
=~
/^\d+$/
if
id
=~
/^\d+$/
Project
.
find_by
(
id:
id
)
Project
.
find_by
(
id:
id
)
else
else
Project
.
find_
with_namespace
(
id
)
Project
.
find_
by_full_path
(
id
)
end
end
end
end
...
...
lib/api/helpers/internal_helpers.rb
View file @
a0586dbc
...
@@ -30,7 +30,7 @@ module API
...
@@ -30,7 +30,7 @@ module API
def
wiki?
def
wiki?
@wiki
||=
project_path
.
end_with?
(
'.wiki'
)
&&
@wiki
||=
project_path
.
end_with?
(
'.wiki'
)
&&
!
Project
.
find_
with_namespace
(
project_path
)
!
Project
.
find_
by_full_path
(
project_path
)
end
end
def
project
def
project
...
@@ -41,7 +41,7 @@ module API
...
@@ -41,7 +41,7 @@ module API
# the wiki repository as well.
# the wiki repository as well.
project_path
.
chomp!
(
'.wiki'
)
if
wiki?
project_path
.
chomp!
(
'.wiki'
)
if
wiki?
Project
.
find_
with_namespace
(
project_path
)
Project
.
find_
by_full_path
(
project_path
)
end
end
end
end
...
...
lib/banzai/cross_project_reference.rb
View file @
a0586dbc
...
@@ -14,7 +14,7 @@ module Banzai
...
@@ -14,7 +14,7 @@ module Banzai
def
project_from_ref
(
ref
)
def
project_from_ref
(
ref
)
return
context
[
:project
]
unless
ref
return
context
[
:project
]
unless
ref
Project
.
find_
with_namespace
(
ref
)
Project
.
find_
by_full_path
(
ref
)
end
end
end
end
end
end
lib/constraints/project_url_constrainer.rb
View file @
a0586dbc
...
@@ -8,6 +8,6 @@ class ProjectUrlConstrainer
...
@@ -8,6 +8,6 @@ class ProjectUrlConstrainer
return
false
return
false
end
end
Project
.
find_
with_namespace
(
full_path
).
present?
Project
.
find_
by_full_path
(
full_path
).
present?
end
end
end
end
lib/gitlab/email/handler/create_issue_handler.rb
View file @
a0586dbc
...
@@ -34,7 +34,7 @@ module Gitlab
...
@@ -34,7 +34,7 @@ module Gitlab
end
end
def
project
def
project
@project
||=
Project
.
find_
with_namespace
(
project_path
)
@project
||=
Project
.
find_
by_full_path
(
project_path
)
end
end
private
private
...
...
lib/gitlab/git_post_receive.rb
View file @
a0586dbc
...
@@ -30,11 +30,11 @@ module Gitlab
...
@@ -30,11 +30,11 @@ module Gitlab
def
retrieve_project_and_type
def
retrieve_project_and_type
@type
=
:project
@type
=
:project
@project
=
Project
.
find_
with_namespace
(
@repo_path
)
@project
=
Project
.
find_
by_full_path
(
@repo_path
)
if
@repo_path
.
end_with?
(
'.wiki'
)
&&
!
@project
if
@repo_path
.
end_with?
(
'.wiki'
)
&&
!
@project
@type
=
:wiki
@type
=
:wiki
@project
=
Project
.
find_
with_namespace
(
@repo_path
.
gsub
(
/\.wiki\z/
,
''
))
@project
=
Project
.
find_
by_full_path
(
@repo_path
.
gsub
(
/\.wiki\z/
,
''
))
end
end
end
end
...
...
lib/tasks/gitlab/cleanup.rake
View file @
a0586dbc
...
@@ -58,7 +58,7 @@ namespace :gitlab do
...
@@ -58,7 +58,7 @@ namespace :gitlab do
sub
(
%r{^/*}
,
''
).
sub
(
%r{^/*}
,
''
).
chomp
(
'.git'
).
chomp
(
'.git'
).
chomp
(
'.wiki'
)
chomp
(
'.wiki'
)
next
if
Project
.
find_
with_namespace
(
repo_with_namespace
)
next
if
Project
.
find_
by_full_path
(
repo_with_namespace
)
new_path
=
path
+
move_suffix
new_path
=
path
+
move_suffix
puts
path
.
inspect
+
' -> '
+
new_path
.
inspect
puts
path
.
inspect
+
' -> '
+
new_path
.
inspect
File
.
rename
(
path
,
new_path
)
File
.
rename
(
path
,
new_path
)
...
...
lib/tasks/gitlab/import.rake
View file @
a0586dbc
...
@@ -29,7 +29,7 @@ namespace :gitlab do
...
@@ -29,7 +29,7 @@ namespace :gitlab do
next
next
end
end
project
=
Project
.
find_
with_namespace
(
path
)
project
=
Project
.
find_
by_full_path
(
path
)
if
project
if
project
puts
" *
#{
project
.
name
}
(
#{
repo_path
}
) exists"
puts
" *
#{
project
.
name
}
(
#{
repo_path
}
) exists"
...
...
lib/tasks/gitlab/sidekiq.rake
View file @
a0586dbc
...
@@ -7,7 +7,7 @@ namespace :gitlab do
...
@@ -7,7 +7,7 @@ namespace :gitlab do
unless
args
.
project
.
present?
unless
args
.
project
.
present?
abort
"Please specify the project you want to drop PostReceive jobs for:
\n
rake gitlab:sidekiq:drop_post_receive[group/project]"
abort
"Please specify the project you want to drop PostReceive jobs for:
\n
rake gitlab:sidekiq:drop_post_receive[group/project]"
end
end
project_path
=
Project
.
find_
with_namespace
(
args
.
project
).
repository
.
path_to_repo
project_path
=
Project
.
find_
by_full_path
(
args
.
project
).
repository
.
path_to_repo
Sidekiq
.
redis
do
|
redis
|
Sidekiq
.
redis
do
|
redis
|
unless
redis
.
exists
(
QUEUE
)
unless
redis
.
exists
(
QUEUE
)
...
...
spec/lib/banzai/cross_project_reference_spec.rb
View file @
a0586dbc
...
@@ -24,7 +24,7 @@ describe Banzai::CrossProjectReference, lib: true do
...
@@ -24,7 +24,7 @@ describe Banzai::CrossProjectReference, lib: true do
it
'returns the referenced project'
do
it
'returns the referenced project'
do
project2
=
double
(
'referenced project'
)
project2
=
double
(
'referenced project'
)
expect
(
Project
).
to
receive
(
:find_
with_namespace
).
expect
(
Project
).
to
receive
(
:find_
by_full_path
).
with
(
'cross/reference'
).
and_return
(
project2
)
with
(
'cross/reference'
).
and_return
(
project2
)
expect
(
project_from_ref
(
'cross/reference'
)).
to
eq
project2
expect
(
project_from_ref
(
'cross/reference'
)).
to
eq
project2
...
...
spec/routing/project_routing_spec.rb
View file @
a0586dbc
...
@@ -2,8 +2,8 @@ require 'spec_helper'
...
@@ -2,8 +2,8 @@ require 'spec_helper'
describe
'project routing'
do
describe
'project routing'
do
before
do
before
do
allow
(
Project
).
to
receive
(
:find_
with_namespace
).
and_return
(
false
)
allow
(
Project
).
to
receive
(
:find_
by_full_path
).
and_return
(
false
)
allow
(
Project
).
to
receive
(
:find_
with_namespace
).
with
(
'gitlab/gitlabhq'
).
and_return
(
true
)
allow
(
Project
).
to
receive
(
:find_
by_full_path
).
with
(
'gitlab/gitlabhq'
).
and_return
(
true
)
end
end
# Shared examples for a resource inside a Project
# Shared examples for a resource inside a Project
...
@@ -86,13 +86,13 @@ describe 'project routing' do
...
@@ -86,13 +86,13 @@ describe 'project routing' do
end
end
context
'name with dot'
do
context
'name with dot'
do
before
{
allow
(
Project
).
to
receive
(
:find_
with_namespace
).
with
(
'gitlab/gitlabhq.keys'
).
and_return
(
true
)
}
before
{
allow
(
Project
).
to
receive
(
:find_
by_full_path
).
with
(
'gitlab/gitlabhq.keys'
).
and_return
(
true
)
}
it
{
expect
(
get
(
'/gitlab/gitlabhq.keys'
)).
to
route_to
(
'projects#show'
,
namespace_id:
'gitlab'
,
id:
'gitlabhq.keys'
)
}
it
{
expect
(
get
(
'/gitlab/gitlabhq.keys'
)).
to
route_to
(
'projects#show'
,
namespace_id:
'gitlab'
,
id:
'gitlabhq.keys'
)
}
end
end
context
'with nested group'
do
context
'with nested group'
do
before
{
allow
(
Project
).
to
receive
(
:find_
with_namespace
).
with
(
'gitlab/subgroup/gitlabhq'
).
and_return
(
true
)
}
before
{
allow
(
Project
).
to
receive
(
:find_
by_full_path
).
with
(
'gitlab/subgroup/gitlabhq'
).
and_return
(
true
)
}
it
{
expect
(
get
(
'/gitlab/subgroup/gitlabhq'
)).
to
route_to
(
'projects#show'
,
namespace_id:
'gitlab/subgroup'
,
id:
'gitlabhq'
)
}
it
{
expect
(
get
(
'/gitlab/subgroup/gitlabhq'
)).
to
route_to
(
'projects#show'
,
namespace_id:
'gitlab/subgroup'
,
id:
'gitlabhq'
)
}
end
end
...
...
spec/workers/post_receive_spec.rb
View file @
a0586dbc
...
@@ -74,7 +74,7 @@ describe PostReceive do
...
@@ -74,7 +74,7 @@ describe PostReceive do
context
"webhook"
do
context
"webhook"
do
it
"fetches the correct project"
do
it
"fetches the correct project"
do
expect
(
Project
).
to
receive
(
:find_
with_namespace
).
with
(
project
.
path_with_namespace
).
and_return
(
project
)
expect
(
Project
).
to
receive
(
:find_
by_full_path
).
with
(
project
.
path_with_namespace
).
and_return
(
project
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
end
end
...
@@ -89,7 +89,7 @@ describe PostReceive do
...
@@ -89,7 +89,7 @@ describe PostReceive do
end
end
it
"asks the project to trigger all hooks"
do
it
"asks the project to trigger all hooks"
do
allow
(
Project
).
to
receive
(
:find_
with_namespace
).
and_return
(
project
)
allow
(
Project
).
to
receive
(
:find_
by_full_path
).
and_return
(
project
)
expect
(
project
).
to
receive
(
:execute_hooks
).
twice
expect
(
project
).
to
receive
(
:execute_hooks
).
twice
expect
(
project
).
to
receive
(
:execute_services
).
twice
expect
(
project
).
to
receive
(
:execute_services
).
twice
...
@@ -97,7 +97,7 @@ describe PostReceive do
...
@@ -97,7 +97,7 @@ describe PostReceive do
end
end
it
"enqueues a UpdateMergeRequestsWorker job"
do
it
"enqueues a UpdateMergeRequestsWorker job"
do
allow
(
Project
).
to
receive
(
:find_
with_namespace
).
and_return
(
project
)
allow
(
Project
).
to
receive
(
:find_
by_full_path
).
and_return
(
project
)
expect
(
UpdateMergeRequestsWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
project
.
owner
.
id
,
any_args
)
expect
(
UpdateMergeRequestsWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
project
.
owner
.
id
,
any_args
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment