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