Permalink
Browse files

fixed the fork task

  • Loading branch information...
drnic committed Mar 21, 2012
1 parent fe192b1 commit 91cceab9daa5c74978e80edf92a60fabbf5f1dea
Showing with 16 additions and 9 deletions.
  1. +16 −9 lib/commands/commands.rb
View
@@ -223,16 +223,23 @@
end
end
- sh "curl -F 'login=#{github_user}' -F 'token=#{github_token}' https://github.com/#{user}/#{repo}/fork"
-
- url = "git@github.com:#{github_user}/#{repo}.git"
- if is_repo
- git "config remote.origin.url #{url}"
- puts "#{user}/#{repo} forked"
+ current_origin = git "config remote.origin.url"
+
+ output_json = sh "curl -F 'login=#{github_user}' -F 'token=#{github_token}' https://github.com/api/v2/json/repos/fork/#{user}/#{repo}"
+ output = JSON.parse(output_json)
+ if output["error"]
+ die output["error"]
else
- puts "Giving GitHub a moment to create the fork..."
- sleep 3
- git_exec "clone #{url}"
+ url = "git@github.com:#{github_user}/#{repo}.git"
+ if is_repo
+ git "config remote.origin.url #{url}"
+ git "config remote.parent.url #{current_origin}"
+ puts "#{user}/#{repo} forked"
+ else
+ puts "Giving GitHub a moment to create the fork..."
+ sleep 3
+ git_exec "clone #{url}"
+ end
end
end

0 comments on commit 91cceab

Please sign in to comment.