Skip to content

Commit

Permalink
Fix up hub submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Ridgewell authored and defunkt committed Apr 21, 2010
1 parent d918ca2 commit 0089a94
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -179,6 +179,17 @@ login" below for details.
$ git compare myfork patch
> open http://github.com/myfork/compare/patch

### git submodule
$ hub submodule add wycats/bundler vendor/bundler
> git submodule add git://github.com/wycats/bundler.git vendor/bundler

$ hub submodule add -p wycats/bundler vendor/bundler
> git submodule add git@github.com:wycats/bundler.git vendor/bundler

$ hub submodule add -b ryppl ryppl/pip vendor/bundler
> git submodule add -b ryppl git://github.com/ryppl/pip.git vendor/pip


### git help

$ git help
Expand Down
14 changes: 14 additions & 0 deletions lib/hub/commands.rb
Expand Up @@ -95,10 +95,24 @@ def clone(args)
#
# $ hub submodule add -p wycats/bundler vendor/bundler
# > git submodule add git@github.com:wycats/bundler.git vendor/bundler
#
# $ hub submodule add -b ryppl ryppl/pip vendor/bundler
# > git submodule add -b ryppl git://github.com/ryppl/pip.git vendor/pip
def submodule(args)
return unless index = args.index('add')
args.delete_at index

branch = args.index('-b') || args.index('--branch')
if branch
args.delete_at branch
branch_name = args.delete_at branch
end

clone(args)

if branch_name
args.insert branch, '-b', branch_name
end
args.insert index, 'add'
end

Expand Down
13 changes: 11 additions & 2 deletions test/hub_test.rb
Expand Up @@ -108,17 +108,26 @@ def test_private_remote_origin_as_normal

def test_public_submodule
input = "submodule add wycats/bundler vendor/bundler"
command = "git submodule add git://github.com/wycats.bundler.git"
command = "git submodule add git://github.com/wycats/bundler.git vendor/bundler"
assert_command input, command
end

def test_private_submodule
input = "submodule add -p grit vendor/grit"
command = "git submodule add git@github.com:tpw/grit.git"
command = "git submodule add git@github.com:tpw/grit.git vendor/grit"
assert_command input, command
end

def test_submodule_branch
input = "submodule add -b ryppl ryppl/pip vendor/pip"
command = "git submodule add -b ryppl git://github.com/ryppl/pip.git vendor/pip"
assert_command input, command
end

def test_submodule_with_args
input = "submodule -q add --bare -- grit grit"
command = "git submodule -q add --bare -- git://github.com/tpw/grit.git grit"
assert_command input, command
end

def test_private_remote
Expand Down

0 comments on commit 0089a94

Please sign in to comment.