Skip to content
Snippets Groups Projects
Commit a0586dbc authored by Adam Pahlevi's avatar Adam Pahlevi
Browse files

replace `find_with_namespace` with `find_by_full_path`

add complete changelog for !8949
parent d777e6f1
No related branches found
No related tags found
No related merge requests found
Showing
with 25 additions and 25 deletions
Loading
Loading
@@ -45,7 +45,7 @@ class Admin::ProjectsController < Admin::ApplicationController
protected
 
def project
@project = Project.find_with_namespace(
@project = Project.find_by_full_path(
[params[:namespace_id], '/', params[:id]].join('')
)
@project || render_404
Loading
Loading
Loading
Loading
@@ -24,7 +24,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
private
 
def project
@project = Project.find_with_namespace(
@project = Project.find_by_full_path(
[params[:namespace_id], '/', params[:project_id]].join('')
)
@project || render_404
Loading
Loading
Loading
Loading
@@ -24,7 +24,7 @@ class Projects::ApplicationController < ApplicationController
end
 
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 @project.path_with_namespace != project_path
Loading
Loading
Loading
Loading
@@ -79,7 +79,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController
if project_id.blank?
@project = nil
else
@project = Project.find_with_namespace("#{params[:namespace_id]}/#{project_id}")
@project = Project.find_by_full_path("#{params[:namespace_id]}/#{project_id}")
end
end
 
Loading
Loading
Loading
Loading
@@ -36,7 +36,7 @@ class Projects::UploadsController < Projects::ApplicationController
namespace = params[:namespace_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?
@uploader = nil
Loading
Loading
Loading
Loading
@@ -37,7 +37,7 @@ module ApplicationHelper
if project_id.is_a?(Project)
project_id
else
Project.find_with_namespace(project_id)
Project.find_by_full_path(project_id)
end
 
if project.avatar_url
Loading
Loading
Loading
Loading
@@ -369,10 +369,6 @@ class Project < ActiveRecord::Base
def group_ids
joins(:namespace).where(namespaces: { type: 'Group' }).select(:namespace_id)
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
 
def lfs_enabled?
Loading
Loading
@@ -1345,6 +1341,6 @@ class Project < ActiveRecord::Base
def pending_delete_twin
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
Loading
Loading
@@ -61,7 +61,7 @@ module Auth
end
 
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
 
actions = actions.select do |action|
Loading
Loading
---
title: replace `find_with_namespace` with `find_by_full_path`
merge_request: 8949
author: Adam Pahlevi
Loading
Loading
@@ -26,7 +26,7 @@ Gitlab::Seeder.quiet do
end
end
 
project = Project.find_with_namespace('gitlab-org/gitlab-test')
project = Project.find_by_full_path('gitlab-org/gitlab-test')
 
params = {
source_branch: 'feature',
Loading
Loading
Loading
Loading
@@ -45,7 +45,7 @@ module API
if id =~ /^\d+$/
Project.find_by(id: id)
else
Project.find_with_namespace(id)
Project.find_by_full_path(id)
end
end
 
Loading
Loading
Loading
Loading
@@ -30,7 +30,7 @@ module API
 
def wiki?
@wiki ||= project_path.end_with?('.wiki') &&
!Project.find_with_namespace(project_path)
!Project.find_by_full_path(project_path)
end
 
def project
Loading
Loading
@@ -41,7 +41,7 @@ module API
# the wiki repository as well.
project_path.chomp!('.wiki') if wiki?
 
Project.find_with_namespace(project_path)
Project.find_by_full_path(project_path)
end
end
 
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ module Banzai
def project_from_ref(ref)
return context[:project] unless ref
 
Project.find_with_namespace(ref)
Project.find_by_full_path(ref)
end
end
end
Loading
Loading
@@ -8,6 +8,6 @@ class ProjectUrlConstrainer
return false
end
 
Project.find_with_namespace(full_path).present?
Project.find_by_full_path(full_path).present?
end
end
Loading
Loading
@@ -34,7 +34,7 @@ module Gitlab
end
 
def project
@project ||= Project.find_with_namespace(project_path)
@project ||= Project.find_by_full_path(project_path)
end
 
private
Loading
Loading
Loading
Loading
@@ -30,11 +30,11 @@ module Gitlab
 
def retrieve_project_and_type
@type = :project
@project = Project.find_with_namespace(@repo_path)
@project = Project.find_by_full_path(@repo_path)
 
if @repo_path.end_with?('.wiki') && !@project
@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
 
Loading
Loading
Loading
Loading
@@ -58,7 +58,7 @@ namespace :gitlab do
sub(%r{^/*}, '').
chomp('.git').
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
puts path.inspect + ' -> ' + new_path.inspect
File.rename(path, new_path)
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@ namespace :gitlab do
next
end
 
project = Project.find_with_namespace(path)
project = Project.find_by_full_path(path)
 
if project
puts " * #{project.name} (#{repo_path}) exists"
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ namespace :gitlab do
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]"
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|
unless redis.exists(QUEUE)
Loading
Loading
Loading
Loading
@@ -24,7 +24,7 @@ describe Banzai::CrossProjectReference, lib: true do
it 'returns the referenced project' do
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)
 
expect(project_from_ref('cross/reference')).to eq project2
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment