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
project].join('')
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
def relative_self_url?(url)
......
......@@ -9,7 +9,6 @@
# needs any special behavior.
module HasRepository
extend ActiveSupport::Concern
include Gitlab::ShellAdapter
include AfterCommitQueue
include Referable
include Gitlab::Utils::StrongMemoize
......@@ -78,7 +77,7 @@ module HasRepository
end
def url_to_repo
gitlab_shell.url_to_repo(full_path)
Gitlab::Shell.url_to_repo(full_path)
end
def ssh_url_to_repo
......
# frozen_string_literal: true
class ProjectWiki
include Gitlab::ShellAdapter
include Storage::LegacyProjectWiki
MARKUPS = {
......@@ -47,7 +46,7 @@ class ProjectWiki
end
def url_to_repo
gitlab_shell.url_to_repo(full_path)
Gitlab::Shell.url_to_repo(full_path)
end
def ssh_url_to_repo
......
......@@ -34,6 +34,14 @@ module Gitlab
.join('GITLAB_SHELL_VERSION')).strip
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
# Create (if necessary) and link the secret token file
......@@ -236,14 +244,6 @@ module Gitlab
false
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 [String] version
......
......@@ -12,7 +12,13 @@ describe Gitlab::Shell do
it { is_expected.to respond_to :remove_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
let(:secret_file) { 'tmp/tests/.secret_shell_test' }
......
......@@ -34,7 +34,7 @@ describe ProjectWiki do
describe "#url_to_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
......
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