Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…oses #13
  • Loading branch information...
commit 05be8a983a19b242b14767d5df5f22c9ef326fc3 1 parent cff1869
@defunkt defunkt authored
Showing with 11 additions and 2 deletions.
  1. +1 −0  HISTORY.md
  2. +10 −2 lib/hub/commands.rb
View
1  HISTORY.md
@@ -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
12 lib/hub/commands.rb
@@ -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.
#
Please sign in to comment.
Something went wrong with that request. Please try again.