Skip to content

Commit

Permalink
fixed the fork task
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Mar 21, 2012
1 parent fe192b1 commit 91cceab
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/commands/commands.rb
Expand Up @@ -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

Expand Down

0 comments on commit 91cceab

Please sign in to comment.