Skip to content

Instantly share code, notes, and snippets.

@rgarner
Created August 25, 2010 20:16
Show Gist options
  • Save rgarner/550197 to your computer and use it in GitHub Desktop.
Save rgarner/550197 to your computer and use it in GitHub Desktop.
def consolidate(*issue_uris)
result = Nokogiri::XML.parse '<issues />'
issue_uris.each do |uri|
fetch_doc(uri).css('issue').each do |issue|
if issue.comments.content.to_i > 0 then
issue.comments.unlink
comments_doc = fetch_doc("#{@comments_base}/#{issue.number.content}")
comments_doc.comments.parent = issue
end
result.root << issue
end
end
result
end
def fetch_doc(url)
response = nil
while true
response = post(url)
if response.code == '403'
$stderr.puts "Sleeping 10..."; sleep 10; next
end
break
end
raise RuntimeError, "Did not fetch #{url} successfully (#{response.code}) with " +
"#{@login}/#{@token}" unless response.is_a? Net::HTTPSuccess
Nokogiri::Slop(response.body)
end
@rgarner
Copy link
Author

rgarner commented Aug 25, 2010

Using Nokogiri::Slop to export issues with their comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment