Browse files

avoid messing up git clone from local repository

Fixes #138
  • Loading branch information...
1 parent 76d8468 commit ce36a32617387d213a68e410330514dfe2689462 @mislav mislav committed Feb 7, 2012
Showing with 12 additions and 2 deletions.
  1. +2 −2 lib/hub/commands.rb
  2. +10 −0 test/hub_test.rb
View
4 lib/hub/commands.rb
@@ -34,7 +34,7 @@ module Commands
# 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 @@ def clone(args)
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('/')
View
10 test/hub_test.rb
@@ -160,6 +160,16 @@ def test_normal_clone_from_path
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"

0 comments on commit ce36a32

Please sign in to comment.