Permalink
Browse files

Smarter clone command uses SSH if current user is repo user.

Conflicts:

	History.txt
	commands/commands.rb
  • Loading branch information...
1 parent 4797f6d commit 05f64586be53c3300a900afe8f63b41e20f76462 @defunkt committed Nov 16, 2008
Showing with 25 additions and 4 deletions.
  1. +9 −0 History.txt
  2. +4 −4 commands/commands.rb
  3. +12 −0 lib/github/command.rb
View
@@ -0,0 +1,9 @@
+== 0.1.4
+
+* Added usage notes to commands. [topfunky]
+* Added config option to set github.user and github.repo. [topfunky]
+* Uses current user to automatically use SSH when cloning own projects.
+
+== 0.1.3
+
+* Original version
@@ -6,7 +6,7 @@
end
desc "Automatically set configuration info, or pass args to specify."
-usage "github [my_username] [my_repo_name]"
+usage "github config [my_username] [my_repo_name]"
command :config do |user, repo|
user ||= ENV['USER']
repo ||= File.basename(FileUtils.pwd)
@@ -16,7 +16,7 @@
end
desc "Open this repo in a web browser."
-usage "github [user] [branch]"
+usage "github browse [user] [branch]"
command :browse do |user, branch|
if helper.project
# if one arg given, treat it as a branch name
@@ -227,7 +227,7 @@
end
end
-desc "Clone a repo."
+desc "Clone a repo. Uses ssh if current user is "
usage "github clone [user] [repo] [dir]"
flags :ssh => "Clone using the git@github.com style url."
command :clone do |user, repo, dir|
@@ -237,7 +237,7 @@
(user, repo), dir = [user.split('/', 2), repo]
end
- if options[:ssh]
+ if options[:ssh] || current_user?(user)
git_exec "clone git@github.com:#{user}/#{repo}.git" + (dir ? " #{dir}" : "")
elsif repo
git_exec "clone git://github.com/#{user}/#{repo}.git" + (dir ? " #{dir}" : "")
View
@@ -52,6 +52,18 @@ def die(message)
exit!
end
+ def github_user
+ git("config --get github.user")
+ end
+
+ def shell_user
+ ENV['USER']
+ end
+
+ def current_user?(user)
+ user == github_user || user == shell_user
+ end
+
class Shell < String
attr_reader :error
attr_reader :out

0 comments on commit 05f6458

Please sign in to comment.