Commit b29eed55 authored by Nick Thomas's avatar Nick Thomas

Promote Gitlab::Shell#url_to_repo to a class method

This method is a static transformation of its arguments so it makes
more sense as a class method - no need for a Gitlab::Shell instance.

This allows us to remove `Gitlab::ShellAdapter` from a few places.
parent 4a676c32
...@@ -66,7 +66,7 @@ module SubmoduleHelper ...@@ -66,7 +66,7 @@ module SubmoduleHelper
project].join('') project].join('')
url_with_dotgit = url_no_dotgit + '.git' url_with_dotgit = url_no_dotgit + '.git'
url_with_dotgit == Gitlab::Shell.new.url_to_repo([namespace, '/', project].join('')) url_with_dotgit == Gitlab::Shell.url_to_repo([namespace, '/', project].join(''))
end end
def relative_self_url?(url) def relative_self_url?(url)
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
# needs any special behavior. # needs any special behavior.
module HasRepository module HasRepository
extend ActiveSupport::Concern extend ActiveSupport::Concern
include Gitlab::ShellAdapter
include AfterCommitQueue include AfterCommitQueue
include Referable include Referable
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
...@@ -78,7 +77,7 @@ module HasRepository ...@@ -78,7 +77,7 @@ module HasRepository
end end
def url_to_repo def url_to_repo
gitlab_shell.url_to_repo(full_path) Gitlab::Shell.url_to_repo(full_path)
end end
def ssh_url_to_repo def ssh_url_to_repo
......
# frozen_string_literal: true # frozen_string_literal: true
class ProjectWiki class ProjectWiki
include Gitlab::ShellAdapter
include Storage::LegacyProjectWiki include Storage::LegacyProjectWiki
MARKUPS = { MARKUPS = {
...@@ -47,7 +46,7 @@ class ProjectWiki ...@@ -47,7 +46,7 @@ class ProjectWiki
end end
def url_to_repo def url_to_repo
gitlab_shell.url_to_repo(full_path) Gitlab::Shell.url_to_repo(full_path)
end end
def ssh_url_to_repo def ssh_url_to_repo
......
...@@ -34,6 +34,14 @@ module Gitlab ...@@ -34,6 +34,14 @@ module Gitlab
.join('GITLAB_SHELL_VERSION')).strip .join('GITLAB_SHELL_VERSION')).strip
end end
# Return a SSH url for a given project path
#
# @param [String] full_path project path (URL)
# @return [String] SSH URL
def url_to_repo(full_path)
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{full_path}.git"
end
private private
# Create (if necessary) and link the secret token file # Create (if necessary) and link the secret token file
...@@ -236,14 +244,6 @@ module Gitlab ...@@ -236,14 +244,6 @@ module Gitlab
false false
end end
# Return a SSH url for a given project path
#
# @param [String] full_path project path (URL)
# @return [String] SSH URL
def url_to_repo(full_path)
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{full_path}.git"
end
# Return GitLab shell version # Return GitLab shell version
# #
# @return [String] version # @return [String] version
......
...@@ -12,7 +12,13 @@ describe Gitlab::Shell do ...@@ -12,7 +12,13 @@ describe Gitlab::Shell do
it { is_expected.to respond_to :remove_repository } it { is_expected.to respond_to :remove_repository }
it { is_expected.to respond_to :fork_repository } it { is_expected.to respond_to :fork_repository }
it { expect(gitlab_shell.url_to_repo('diaspora')).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "diaspora.git") } describe '.url_to_repo' do
let(:full_path) { 'diaspora/disaspora-rails' }
subject { described_class.url_to_repo(full_path) }
it { is_expected.to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + full_path + '.git') }
end
describe 'memoized secret_token' do describe 'memoized secret_token' do
let(:secret_file) { 'tmp/tests/.secret_shell_test' } let(:secret_file) { 'tmp/tests/.secret_shell_test' }
......
...@@ -34,7 +34,7 @@ describe ProjectWiki do ...@@ -34,7 +34,7 @@ describe ProjectWiki do
describe "#url_to_repo" do describe "#url_to_repo" do
it "returns the correct ssh url to the repo" do it "returns the correct ssh url to the repo" do
expect(subject.url_to_repo).to eq(gitlab_shell.url_to_repo(subject.full_path)) expect(subject.url_to_repo).to eq(Gitlab::Shell.url_to_repo(subject.full_path))
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