Created
August 25, 2010 20:16
-
-
Save rgarner/550197 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using Nokogiri::Slop to export issues with their comments