From 9ad171ab78bd8bfb163fd21a8b9307398032317d Mon Sep 17 00:00:00 2001 From: Chris Salzberg Date: Wed, 24 Sep 2014 00:29:06 +0900 Subject: [PATCH] Pass destination when cloning url. --- lib/homesick/cli.rb | 4 ++-- spec/homesick_cli_spec.rb | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/homesick/cli.rb b/lib/homesick/cli.rb index fdb5fba..035d4b9 100644 --- a/lib/homesick/cli.rb +++ b/lib/homesick/cli.rb @@ -50,8 +50,8 @@ module Homesick git_clone "https://github.com/#{Regexp.last_match[1]}.git", destination: destination elsif uri =~ /%r([^%r]*?)(\.git)?\Z/ || uri =~ /[^:]+:([^:]+)(\.git)?\Z/ - destination = Pathname.new(Regexp.last_match[1]) - git_clone uri + destination = Pathname.new(Regexp.last_match[1].gsub(/\.git$/,'')).basename + git_clone uri, destination: destination else fail "Unknown URI format: #{uri}" end diff --git a/spec/homesick_cli_spec.rb b/spec/homesick_cli_spec.rb index f3a977f..bbb62f9 100644 --- a/spec/homesick_cli_spec.rb +++ b/spec/homesick_cli_spec.rb @@ -81,34 +81,39 @@ describe Homesick::CLI do it 'clones git repo like git://host/path/to.git' do expect(homesick).to receive(:git_clone) - .with('git://github.com/technicalpickles/pickled-vim.git') + .with('git://github.com/technicalpickles/pickled-vim.git', + destination: Pathname.new('pickled-vim')) homesick.clone 'git://github.com/technicalpickles/pickled-vim.git' end it 'clones git repo like git@host:path/to.git' do expect(homesick).to receive(:git_clone) - .with('git@github.com:technicalpickles/pickled-vim.git') + .with('git@github.com:technicalpickles/pickled-vim.git', + destination: Pathname.new('pickled-vim')) homesick.clone 'git@github.com:technicalpickles/pickled-vim.git' end it 'clones git repo like http://host/path/to.git' do expect(homesick).to receive(:git_clone) - .with('http://github.com/technicalpickles/pickled-vim.git') + .with('http://github.com/technicalpickles/pickled-vim.git', + destination: Pathname.new('pickled-vim')) homesick.clone 'http://github.com/technicalpickles/pickled-vim.git' end it 'clones git repo like http://host/path/to' do expect(homesick).to receive(:git_clone) - .with('http://github.com/technicalpickles/pickled-vim') + .with('http://github.com/technicalpickles/pickled-vim', + destination: Pathname.new('pickled-vim')) homesick.clone 'http://github.com/technicalpickles/pickled-vim' end it 'clones git repo like host-alias:repos.git' do - expect(homesick).to receive(:git_clone).with('gitolite:pickled-vim.git') + expect(homesick).to receive(:git_clone).with('gitolite:pickled-vim.git', + destination: Pathname.new('pickled-vim')) homesick.clone 'gitolite:pickled-vim.git' end