Skip to content

Commit

Permalink
Fix git remote add -f user
Browse files Browse the repository at this point in the history
  • Loading branch information
defunkt committed Mar 8, 2010
1 parent ca1e956 commit a1845d2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
@@ -1,3 +1,7 @@
## 1.0.2 (2010-03-07)

* Bugfix: `hub remote -f name` (for real this time)

## 1.0.1 (2010-03-05)

* Bugfix: `hub remote -f name`
Expand Down
8 changes: 5 additions & 3 deletions lib/hub/commands.rb
Expand Up @@ -119,7 +119,9 @@ def remote(args)

if args.words[-2] == args.words[1]
# rtomayko/tilt => rtomayko
args[-1] = user
# Make sure you dance around flags.
idx = args.index( args.words[-1] )
args[idx] = user
else
# They're specifying the remote name manually (e.g.
# git remote add blah rtomayko/tilt), so just drop the last
Expand All @@ -129,15 +131,15 @@ def remote(args)

args << url % [ user, repo ]
elsif args.last !~ /:|\//
if args[2] == 'origin' && args[3].nil?
if args.words[2] == 'origin' && args.words[3].nil?
# Origin special case.
user = github_user
else
# Assume no : or / means GitHub user.
user = args.last
end

if args[-2] != args[1]
if args.words[-2] != args.words[1]
# They're specifying the remote name manually (e.g.
# git remote add blah rtomayko), so just drop the last
# argument.
Expand Down
6 changes: 6 additions & 0 deletions test/hub_test.rb
Expand Up @@ -117,6 +117,12 @@ def test_public_remote
assert_command input, command
end

def test_public_remote_f
input = "remote add -f rtomayko"
command = "git remote add -f rtomayko git://github.com/rtomayko/hub.git"
assert_command input, command
end

def test_named_public_remote
input = "remote add origin rtomayko"
command = "git remote add origin git://github.com/rtomayko/hub.git"
Expand Down

0 comments on commit a1845d2

Please sign in to comment.