Skip to content

Commit

Permalink
FIX: Accept github theme urls with a trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaylorhq committed Jun 4, 2019
1 parent 9585a16 commit 0508546
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/theme_store/git_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ThemeStore::GitImporter
def initialize(url, private_key: nil, branch: nil)
@url = url
if @url.start_with?("https://github.com") && !@url.end_with?(".git")
@url = @url.gsub(/\/$/, '')
@url += ".git"
end
@temp_folder = "#{Pathname.new(Dir.tmpdir).realpath}/discourse_theme_#{SecureRandom.hex}"
Expand Down
8 changes: 8 additions & 0 deletions spec/components/theme_store/git_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
context "#import" do

let(: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" }

Expand All @@ -27,6 +28,13 @@
importer.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" do
Discourse::Utils.expects(:execute_command).with({
'GIT_SSH_COMMAND' => "ssh -i #{@ssh_folder}/id_rsa -o StrictHostKeyChecking=no"
Expand Down

0 comments on commit 0508546

Please sign in to comment.