Skip to content

Commit

Permalink
Add hub remote origin shortcut. Assumes your GitHub login.
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Feb 13, 2010
1 parent fb5a21c commit 6f08436
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -128,6 +128,9 @@ superpowers:
$ git remote add -p rtomayko
> git remote add rtomayko git@github.com:rtomayko/CURRENT_REPO.git

$ git remote add origin
> git remote add origin git://github.com/YOUR_USER/CURRENT_REPO.git

### git init

$ git init -g
Expand Down
7 changes: 7 additions & 0 deletions lib/hub/commands.rb
Expand Up @@ -91,6 +91,9 @@ def clone(args)
#
# $ hub remote add -p mojombo
# > git remote add mojombo git@github.com:mojombo/THIS_REPO.git
#
# $ hub remote add origin
# > git remote add origin git://github.com/YOUR_LOGIN/THIS_REPO.git
def remote(args)
return unless args[1] == 'add'

Expand All @@ -100,6 +103,10 @@ def remote(args)
ssh = args.delete('-p')
user = args.last
url = ssh ? PRIVATE : PUBLIC

# Origin special case.
user = github_user if args[2] == 'origin'

args << url % [ user, REPO ]
end
end
Expand Down
6 changes: 5 additions & 1 deletion man/hub.1.ron
Expand Up @@ -39,7 +39,8 @@ After configuring the alias, the following commands have superpowers:
Add remote "git://github.com/<USER>/<REPOSITORY>.git" as with
git-remote(1). When /<REPOSITORY> is omitted, the basename of the
current working directory is used. With `-p`, use private remote
"git@github.com:<USER>/<REPOSITORY>.git".
"git@github.com:<USER>/<REPOSITORY>.git". If <USER> is "origin"
then uses your GitHub login.

* `git push` <REMOTE-1>,<REMOTE-2>,...,<REMOTE-N> <REF>:
Push <REF> to each of <REMOTE-1> through <REMOTE-N> by executing
Expand Down Expand Up @@ -95,6 +96,9 @@ cloning:
$ git remote add -p rtomayko
> git remote add rtomayko git@github.com:rtomayko/CURRENT_REPO.git

$ git remote add origin
> git remote add origingit://github.com/YOUR_USER/CURRENT_REPO.git

### git init

$ git init -g
Expand Down
12 changes: 12 additions & 0 deletions test/hub_test.rb
Expand Up @@ -76,6 +76,18 @@ def test_normal_clone_from_path
assert_command input, command
end

def test_remote_origin
input = "remote add origin"
command = "git remote add origin git://github.com/tpw/hub.git"
assert_command input, command
end

def test_private_remote_origin
input = "remote add -p origin"
command = "git remote add origin git@github.com:tpw/hub.git"
assert_command input, command
end

def test_private_remote
input = "remote add -p rtomayko"
command = "git remote add rtomayko git@github.com:rtomayko/hub.git"
Expand Down

0 comments on commit 6f08436

Please sign in to comment.