Remove .git suffix on destination directory if URL ends with it.

For example, the following:

    homesick clone git://github.com/technicalpickles/pickled-vim.git

should produce a castle directory of:

    $HOME/.homesick/repos/pickled-vim
This commit is contained in:
Fletcher Nichol
2013-06-16 10:47:53 -06:00
parent e530df7239
commit 024856e538
2 changed files with 9 additions and 4 deletions

View File

@@ -3,10 +3,7 @@ class Homesick
# TODO move this to be more like thor's template, empty_directory, etc
def git_clone(repo, config = {})
config ||= {}
destination = config[:destination] || begin
repo =~ /([^\/]+)(?:\.git)?$/
$1
end
destination = config[:destination] || File.basename(repo, '.git')
destination = Pathname.new(destination) unless destination.kind_of?(Pathname)
FileUtils.mkdir_p destination.dirname