avoid messing up git clone from local repository

Fixes #138
This commit is contained in:
Mislav Marohnić 2012-02-07 19:22:51 +01:00
Родитель 76d8468673
Коммит ce36a32617
2 изменённых файлов: 12 добавлений и 2 удалений

Просмотреть файл

@ -34,7 +34,7 @@ module Hub
# provides git interrogation methods
extend Context
NAME_RE = /[\w.-]+/
NAME_RE = /\w[\w.-]*/
OWNER_RE = /[a-zA-Z0-9-]+/
NAME_WITH_OWNER_RE = /^(?:#{NAME_RE}|#{OWNER_RE}\/#{NAME_RE})$/
@ -181,7 +181,7 @@ module Hub
else
# $ hub clone rtomayko/tilt
# $ hub clone tilt
if arg =~ NAME_WITH_OWNER_RE
if arg =~ NAME_WITH_OWNER_RE and !File.directory?(arg)
# FIXME: this logic shouldn't be duplicated here!
name, owner = arg, nil
owner, name = name.split('/', 2) if name.index('/')

Просмотреть файл

@ -160,6 +160,16 @@ class HubTest < Test::Unit::TestCase
assert_forwarded "clone ./test"
end
def test_unchanged_clone_from_existing_directory
stub_no_git_repo
assert_forwarded "clone test"
end
def test_local_clone_with_destination
stub_no_git_repo
assert_forwarded "clone -l . ../copy"
end
def test_clone_with_host_alias
stub_no_git_repo
assert_forwarded "clone server:git/repo.git"