Commit cb10f5b0 authored by James Lopez's avatar James Lopez

Merge branch 'fj-rename-identifer-for-subject-method' into 'master'

Rename identifier_for_subject method to identifier_for_repositorable

See merge request gitlab-org/gitlab!23168
parents 6b7700ac ecc9ca02
......@@ -2203,7 +2203,7 @@ class Project < ApplicationRecord
end
def reference_counter(type: Gitlab::GlRepository::PROJECT)
Gitlab::ReferenceCounter.new(type.identifier_for_subject(self))
Gitlab::ReferenceCounter.new(type.identifier_for_repositorable(self))
end
def badges
......
......@@ -65,7 +65,7 @@ class ProjectWiki
# Returns the Gitlab::Git::Wiki object.
def wiki
@wiki ||= begin
gl_repository = Gitlab::GlRepository::WIKI.identifier_for_subject(project)
gl_repository = Gitlab::GlRepository::WIKI.identifier_for_repositorable(project)
raw_repository = Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git', gl_repository, full_path)
create_repo!(raw_repository) unless raw_repository.exists?
......
......@@ -1177,7 +1177,7 @@ class Repository
def initialize_raw_repository
Gitlab::Git::Repository.new(project.repository_storage,
disk_path + '.git',
repo_type.identifier_for_subject(project),
repo_type.identifier_for_repositorable(project),
project.full_path)
end
end
......
......@@ -20,7 +20,7 @@ module EE
if ::Gitlab::Geo.primary?
# This ID is used by the /internal/post_receive API call
gl_id = ::Gitlab::GlId.gl_id(user)
gl_repository = repo_type.identifier_for_subject(project)
gl_repository = repo_type.identifier_for_repositorable(project)
node_id = params["geo_node_id"]
::Gitlab::Geo::GitPushHttp.new(gl_id, gl_repository).cache_referrer_node(node_id)
end
......
......@@ -118,7 +118,7 @@ describe API::Internal::Base do
context "for design repositories" do
set(:project) { create(:project) }
let(:gl_repository) { EE::Gitlab::GlRepository::DESIGN.identifier_for_subject(project) }
let(:gl_repository) { EE::Gitlab::GlRepository::DESIGN.identifier_for_repositorable(project) }
it "does not allow access" do
post(api("/internal/allowed"),
......
......@@ -385,7 +385,7 @@ describe "Git HTTP requests (Geo)", :geo do
it 'returns a 200' do
is_expected.to have_gitlab_http_status(:ok)
expect(json_response['GL_ID']).to match("user-#{user.id}")
expect(json_response['GL_REPOSITORY']).to match(Gitlab::GlRepository::PROJECT.identifier_for_subject(project))
expect(json_response['GL_REPOSITORY']).to match(Gitlab::GlRepository::PROJECT.identifier_for_repositorable(project))
end
end
end
......
......@@ -118,7 +118,7 @@ module API
# Project id to pass between components that don't share/don't have
# access to the same filesystem mounts
def gl_repository
repo_type.identifier_for_subject(project)
repo_type.identifier_for_repositorable(project)
end
def gl_project_path
......
......@@ -13,8 +13,8 @@ module Gitlab
@repository_accessor = repository_accessor
end
def identifier_for_subject(subject)
"#{name}-#{subject.id}"
def identifier_for_repositorable(repositorable)
"#{name}-#{repositorable.id}"
end
def fetch_id(identifier)
......@@ -34,8 +34,8 @@ module Gitlab
project? ? "" : ".#{name}"
end
def repository_for(subject)
repository_accessor.call(subject)
def repository_for(repositorable)
repository_accessor.call(repositorable)
end
end
end
......
......@@ -24,7 +24,7 @@ module Gitlab
attrs = {
GL_ID: Gitlab::GlId.gl_id(user),
GL_REPOSITORY: repo_type.identifier_for_subject(repository.project),
GL_REPOSITORY: repo_type.identifier_for_repositorable(repository.project),
GL_USERNAME: user&.username,
ShowAllRefs: show_all_refs,
Repository: repository.gitaly_repository.to_h,
......
......@@ -3992,7 +3992,7 @@ describe Project do
end
it 'schedules HashedStorage::ProjectMigrateWorker with delayed start when the project repo is in use' do
Gitlab::ReferenceCounter.new(Gitlab::GlRepository::PROJECT.identifier_for_subject(project)).increase
Gitlab::ReferenceCounter.new(Gitlab::GlRepository::PROJECT.identifier_for_repositorable(project)).increase
expect(HashedStorage::ProjectMigrateWorker).to receive(:perform_in)
......@@ -4000,7 +4000,7 @@ describe Project do
end
it 'schedules HashedStorage::ProjectMigrateWorker with delayed start when the wiki repo is in use' do
Gitlab::ReferenceCounter.new(Gitlab::GlRepository::WIKI.identifier_for_subject(project)).increase
Gitlab::ReferenceCounter.new(Gitlab::GlRepository::WIKI.identifier_for_repositorable(project)).increase
expect(HashedStorage::ProjectMigrateWorker).to receive(:perform_in)
......
......@@ -268,7 +268,7 @@ describe API::Internal::Base do
end
context 'with env passed as a JSON' do
let(:gl_repository) { Gitlab::GlRepository::WIKI.identifier_for_subject(project) }
let(:gl_repository) { Gitlab::GlRepository::WIKI.identifier_for_repositorable(project) }
it 'sets env in RequestStore' do
obj_dir_relative = './objects'
......@@ -1054,9 +1054,9 @@ describe API::Internal::Base do
def gl_repository_for(project_or_wiki)
case project_or_wiki
when ProjectWiki
Gitlab::GlRepository::WIKI.identifier_for_subject(project_or_wiki.project)
Gitlab::GlRepository::WIKI.identifier_for_repositorable(project_or_wiki.project)
when Project
Gitlab::GlRepository::PROJECT.identifier_for_subject(project_or_wiki)
Gitlab::GlRepository::PROJECT.identifier_for_repositorable(project_or_wiki)
else
nil
end
......
# frozen_string_literal: true
shared_examples 'a repo type' do
describe "#identifier_for_subject" do
subject { described_class.identifier_for_subject(project) }
describe "#identifier_for_repositorable" do
subject { described_class.identifier_for_repositorable(project) }
it { is_expected.to eq(expected_identifier) }
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment