mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:29:30 +08:00
FIX: Accept github theme urls with a trailing slash
This commit is contained in:
parent
9585a16264
commit
0508546fd2
|
@ -11,6 +11,7 @@ class ThemeStore::GitImporter
|
||||||
def initialize(url, private_key: nil, branch: nil)
|
def initialize(url, private_key: nil, branch: nil)
|
||||||
@url = url
|
@url = url
|
||||||
if @url.start_with?("https://github.com") && !@url.end_with?(".git")
|
if @url.start_with?("https://github.com") && !@url.end_with?(".git")
|
||||||
|
@url = @url.gsub(/\/$/, '')
|
||||||
@url += ".git"
|
@url += ".git"
|
||||||
end
|
end
|
||||||
@temp_folder = "#{Pathname.new(Dir.tmpdir).realpath}/discourse_theme_#{SecureRandom.hex}"
|
@temp_folder = "#{Pathname.new(Dir.tmpdir).realpath}/discourse_theme_#{SecureRandom.hex}"
|
||||||
|
|
|
@ -10,6 +10,7 @@ describe ThemeStore::GitImporter do
|
||||||
context "#import" do
|
context "#import" do
|
||||||
|
|
||||||
let(:url) { "https://github.com/example/example.git" }
|
let(:url) { "https://github.com/example/example.git" }
|
||||||
|
let(:trailing_slash_url) { "https://github.com/example/example/" }
|
||||||
let(:ssh_url) { "git@github.com:example/example.git" }
|
let(:ssh_url) { "git@github.com:example/example.git" }
|
||||||
let(:branch) { "dev" }
|
let(:branch) { "dev" }
|
||||||
|
|
||||||
|
@ -27,6 +28,13 @@ describe ThemeStore::GitImporter do
|
||||||
importer.import!
|
importer.import!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should work with trailing slash url" do
|
||||||
|
Discourse::Utils.expects(:execute_command).with("git", "clone", url, @temp_folder)
|
||||||
|
|
||||||
|
importer = ThemeStore::GitImporter.new(trailing_slash_url)
|
||||||
|
importer.import!
|
||||||
|
end
|
||||||
|
|
||||||
it "should import from ssh url" do
|
it "should import from ssh url" do
|
||||||
Discourse::Utils.expects(:execute_command).with({
|
Discourse::Utils.expects(:execute_command).with({
|
||||||
'GIT_SSH_COMMAND' => "ssh -i #{@ssh_folder}/id_rsa -o StrictHostKeyChecking=no"
|
'GIT_SSH_COMMAND' => "ssh -i #{@ssh_folder}/id_rsa -o StrictHostKeyChecking=no"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user