Skip to content

Commit

Permalink
avoid messing up git clone from local repository
Browse files Browse the repository at this point in the history
Fixes #138
  • Loading branch information
mislav committed Feb 7, 2012
1 parent 76d8468 commit ce36a32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/hub/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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})$/

Expand Down Expand Up @@ -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('/')
Expand Down
10 changes: 10 additions & 0 deletions test/hub_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit ce36a32

Please sign in to comment.