Permalink
Browse files

Merge pull request #83 from ajddesign/master

github create & github config
  • Loading branch information...
2 parents bfd7bde + c82d361 commit 8ef0c3087d2e5d1f6fe328c06974d787b47df423 @drnic drnic committed Apr 15, 2012
Showing with 17 additions and 11 deletions.
  1. +17 −11 lib/commands/commands.rb
@@ -20,7 +20,7 @@
desc "Automatically set configuration info, or pass args to specify."
usage "github config [my_username] [my_repo_name]"
command :config do |user, repo|
- user ||= ENV['USER']
+ user ||= "#{github_user}"
repo ||= File.basename(FileUtils.pwd)
git "config --global github.user #{user}"
git "config github.repo #{repo}"
@@ -193,16 +193,22 @@
flags :rst => 'Create README.rst'
flags :private => 'Create private repository'
command :create do |repo|
- sh "curl -F 'repository[name]=#{repo}' -F 'repository[public]=#{!options[:private]}' -F 'login=#{github_user}' -F 'token=#{github_token}' https://github.com/repositories"
- mkdir repo
- cd repo
- git "init"
- extension = options.keys.first
- touch extension ? "README.#{extension}" : "README"
- git "add *"
- git "commit -m 'First commit!'"
- git "remote add origin git@github.com:#{github_user}/#{repo}.git"
- git_exec "push origin master"
+ command = "curl -F 'name=#{repo}' -F 'public=#{options[:private] ? 0 : 1}' -F 'login=#{github_user}' -F 'token=#{github_token}' https://github.com/api/v2/json/repos/create"
+ output_json = sh command
+ output = JSON.parse(output_json)
+ if output["error"]
+ die output["error"]
+ else
+ mkdir repo
+ cd repo
+ git "init"
+ extension = options.keys.first
+ touch extension ? "README.#{extension}" : "README"
+ git "add *"
+ git "commit -m 'First commit!'"
+ git "remote add origin git@github.com:#{github_user}/#{repo}.git"
+ git_exec "push origin master"
+ end
end
desc "Forks a GitHub repository"

0 comments on commit 8ef0c30

Please sign in to comment.