Skip to content

Commit

Permalink
better error handling in create-from-local
Browse files Browse the repository at this point in the history
  * check output of command
  * deal properly with spaces etc. in repo/dir names
  • Loading branch information
jberkel authored and drnic committed Mar 10, 2010
1 parent 9e43f50 commit 2f6daf8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/commands/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}' http://github.com/repositories"
git "remote add origin git@github.com:#{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}' http://github.com/repositories"
if created.out =~ %r{You are being <a href="http://github.com/#{github_user}/([^"]+)"}
git "remote add origin git@github.com:#{github_user}/#{$1}.git"
git_exec "push origin master"
else
#TODO try to explain why it failed
die "error creating repository"
end
end

desc "Search GitHub for the given repository name."
Expand Down

0 comments on commit 2f6daf8

Please sign in to comment.