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
@storage ||= Storage::Hashed.new(self, prefix: Storage::Hashed::SNIPPET_REPOSITORY_PATH_PREFIX)
end
# This is the full_path used to identify the
# the snippet repository. It will be used mostly
# for logging purposes.
# This is the full_path used to identify the the snippet repository.
override :full_path
def full_path
return unless persisted?
......@@ -303,7 +301,7 @@ class Snippet < ApplicationRecord
@full_path ||= begin
components = []
components << project.full_path if project_id?
components << '@snippets'
components << 'snippets'
components << self.id
components.join('/')
end
......
......@@ -20,23 +20,6 @@ module Geo
false
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
model_record.repository
end
......
......@@ -4,9 +4,6 @@ module Gitlab
module RepositoryUrlBuilder
class << self
def build(path, protocol: :ssh)
# TODO: See https://gitlab.com/gitlab-org/gitlab/-/issues/213021
path = path.sub('@snippets', 'snippets')
case protocol
when :ssh
ssh_url(path)
......
......@@ -20,9 +20,8 @@ RSpec.describe PersonalSnippet do
it_behaves_like 'model with repository' do
let_it_be(:container) { create(:personal_snippet, :repository) }
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_repo_url_path) { "snippets/#{container.id}" }
end
describe '#parent_user' do
......
......@@ -36,8 +36,7 @@ RSpec.describe ProjectSnippet do
it_behaves_like 'model with repository' do
let_it_be(:container) { create(:project_snippet, :repository) }
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_repo_url_path) { "#{container.project.full_path}/snippets/#{container.id}" }
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