A platform for community discussion. Free, open, simple.
FIX: Accept github theme urls with a trailing slash
David Taylor0508546fd275
diff --git a/lib/theme_store/git_importer.rb b/lib/theme_store/git_importer.rbindex 6d8cee3c87d..673e9a45945 100644--- a/lib/theme_store/git_importer.rb+++ b/lib/theme_store/git_importer.rb@@ -11,6 +11,7 @@ class ThemeStore::GitImporterdef initialize(url, private_key: nil, branch: nil)@url = urlif @url.start_with?("https://github.com") && [email protected]_with?(".git")+ @url = @url.gsub(/\/$/, '')@url += ".git"end@temp_folder = "#{Pathname.new(Dir.tmpdir).realpath}/discourse_theme_#{SecureRandom.hex}"diff --git a/spec/components/theme_store/git_importer_spec.rb b/spec/components/theme_store/git_importer_spec.rbindex 0df9836f908..46783d5c38f 100644--- a/spec/components/theme_store/git_importer_spec.rb+++ b/spec/components/theme_store/git_importer_spec.rb@@ -10,6 +10,7 @@ describe ThemeStore::GitImporter docontext "#import" dolet(:url) { "https://github.com/example/example.git" }+ let(:trailing_slash_url) { "https://github.com/example/example/" }let(:ssh_url) { "[email protected]:example/example.git" }let(:branch) { "dev" }@@ -27,6 +28,13 @@ describe ThemeStore::GitImporter doimporter.import!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" doDiscourse::Utils.expects(:execute_command).with({'GIT_SSH_COMMAND' => "ssh -i #{@ssh_folder}/id_rsa -o StrictHostKeyChecking=no"