Browse files

better error handling in create-from-local

  * check output of command
  * deal properly with spaces etc. in repo/dir names
  • Loading branch information...
1 parent 9e43f50 commit 2f6daf871fd6816c8b01f0a6d0583c7aaadbbecb @jberkel jberkel committed with drnic Mar 9, 2010
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/commands/commands.rb
11 lib/commands/commands.rb
@@ -233,9 +233,14 @@
repo = File.basename(cwd)
is_repo = !git("status").match(/fatal/)
raise "Not a git repository. Use gh create instead" unless is_repo
- sh "curl -F 'repository[name]=#{repo}' -F 'repository[public]=#{!options[:private].inspect}' -F 'login=#{github_user}' -F 'token=#{github_token}'"
- git "remote add origin{github_user}/#{repo}.git"
- git_exec "push origin master"
+ created = sh "curl -F 'repository[name]=#{repo}' -F 'repository[public]=#{!options[:private].inspect}' -F 'login=#{github_user}' -F 'token=#{github_token}'"
+ if created.out =~ %r{You are being <a href="{github_user}/([^"]+)"}
+ git "remote add origin{github_user}/#{$1}.git"
+ git_exec "push origin master"
+ else
+ #TODO try to explain why it failed
+ die "error creating repository"
+ end
desc "Search GitHub for the given repository name."

0 comments on commit 2f6daf8

Please sign in to comment.