Permalink
Browse files

Use the origin url to find the repo name. Thanks akahn and mislav! Cl…

…oses #13
  • Loading branch information...
defunkt committed Dec 24, 2009
1 parent cff1869 commit 05be8a983a19b242b14767d5df5f22c9ef326fc3
Showing with 11 additions and 2 deletions.
  1. +1 −0 HISTORY.md
  2. +10 −2 lib/hub/commands.rb
View
@@ -6,6 +6,7 @@
* Respect git behavior when pager is empty string
* `git push` multi-remote support
* `hub.http-clone` configuration setting
+* Use the origin url to find the repo name
## 0.1.3 (2009-12-11)
View
@@ -32,13 +32,21 @@ module Commands
extend self
# Templates and useful information.
+ USER = `git config --global github.user`.chomp
+ ORIGIN = `git config remote.origin.url`.chomp
HTTP_CLONE = `git config --global hub.http-clone`.chomp == 'yes'
PUBLIC = (HTTP_CLONE ? 'http' : 'git') + '://github.com/%s/%s.git'
PRIVATE = 'git@github.com:%s/%s.git'
- USER = `git config --global github.user`.chomp
- REPO = `basename $(pwd)`.chomp
LGHCONF = "http://github.com/guides/local-github-config"
+ # Set the repo name based on the current origin or, as a fallback,
+ # the cwd.
+ if ORIGIN =~ %r{\bgithub\.com[:/](.+)/(.+).git$}
+ REPO = $2
+ else
+ REPO = `basename $(pwd)`.chomp
+ end
+
# $ hub clone rtomayko/tilt
# > git clone git://github.com/rtomayko/tilt.
#

0 comments on commit 05be8a9

Please sign in to comment.