Commit 6673735f authored by Nick Thomas's avatar Nick Thomas

Merge branch '213021-normalize-snippets-full-path' into 'master'

Remove '@' from Snippet.full_path

See merge request gitlab-org/gitlab!45882
parents 895ad1af bc508f91
...@@ -293,9 +293,7 @@ class Snippet < ApplicationRecord ...@@ -293,9 +293,7 @@ class Snippet < ApplicationRecord
@storage ||= Storage::Hashed.new(self, prefix: Storage::Hashed::SNIPPET_REPOSITORY_PATH_PREFIX) @storage ||= Storage::Hashed.new(self, prefix: Storage::Hashed::SNIPPET_REPOSITORY_PATH_PREFIX)
end end
# This is the full_path used to identify the # This is the full_path used to identify the the snippet repository.
# the snippet repository. It will be used mostly
# for logging purposes.
override :full_path override :full_path
def full_path def full_path
return unless persisted? return unless persisted?
...@@ -303,7 +301,7 @@ class Snippet < ApplicationRecord ...@@ -303,7 +301,7 @@ class Snippet < ApplicationRecord
@full_path ||= begin @full_path ||= begin
components = [] components = []
components << project.full_path if project_id? components << project.full_path if project_id?
components << '@snippets' components << 'snippets'
components << self.id components << self.id
components.join('/') components.join('/')
end end
......
...@@ -20,23 +20,6 @@ module Geo ...@@ -20,23 +20,6 @@ module Geo
false false
end end
# Once https://gitlab.com/gitlab-org/gitlab/-/issues/213021 is fixed
# this method can be removed
def jwt_authentication_header
authorization = ::Gitlab::Geo::RepoSyncRequest.new(
scope: repository.full_path.sub('@snippets', 'snippets')
).authorization
{ "http.#{remote_url}.extraHeader" => "Authorization: #{authorization}" }
end
# Once https://gitlab.com/gitlab-org/gitlab/-/issues/213021 is fixed
# this method can be removed
def remote_url
url = Gitlab::Geo.primary_node.repository_url(repository)
url.sub('@snippets', 'snippets')
end
def repository def repository
model_record.repository model_record.repository
end end
......
...@@ -4,9 +4,6 @@ module Gitlab ...@@ -4,9 +4,6 @@ module Gitlab
module RepositoryUrlBuilder module RepositoryUrlBuilder
class << self class << self
def build(path, protocol: :ssh) def build(path, protocol: :ssh)
# TODO: See https://gitlab.com/gitlab-org/gitlab/-/issues/213021
path = path.sub('@snippets', 'snippets')
case protocol case protocol
when :ssh when :ssh
ssh_url(path) ssh_url(path)
......
...@@ -20,9 +20,8 @@ RSpec.describe PersonalSnippet do ...@@ -20,9 +20,8 @@ RSpec.describe PersonalSnippet do
it_behaves_like 'model with repository' do it_behaves_like 'model with repository' do
let_it_be(:container) { create(:personal_snippet, :repository) } let_it_be(:container) { create(:personal_snippet, :repository) }
let(:stubbed_container) { build_stubbed(:personal_snippet) } let(:stubbed_container) { build_stubbed(:personal_snippet) }
let(:expected_full_path) { "@snippets/#{container.id}" } let(:expected_full_path) { "snippets/#{container.id}" }
let(:expected_web_url_path) { "-/snippets/#{container.id}" } let(:expected_web_url_path) { "-/snippets/#{container.id}" }
let(:expected_repo_url_path) { "snippets/#{container.id}" }
end end
describe '#parent_user' do describe '#parent_user' do
......
...@@ -36,8 +36,7 @@ RSpec.describe ProjectSnippet do ...@@ -36,8 +36,7 @@ RSpec.describe ProjectSnippet do
it_behaves_like 'model with repository' do it_behaves_like 'model with repository' do
let_it_be(:container) { create(:project_snippet, :repository) } let_it_be(:container) { create(:project_snippet, :repository) }
let(:stubbed_container) { build_stubbed(:project_snippet) } let(:stubbed_container) { build_stubbed(:project_snippet) }
let(:expected_full_path) { "#{container.project.full_path}/@snippets/#{container.id}" } let(:expected_full_path) { "#{container.project.full_path}/snippets/#{container.id}" }
let(:expected_web_url_path) { "#{container.project.full_path}/-/snippets/#{container.id}" } let(:expected_web_url_path) { "#{container.project.full_path}/-/snippets/#{container.id}" }
let(:expected_repo_url_path) { "#{container.project.full_path}/snippets/#{container.id}" }
end end
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