From 3c0a713a379025c079f8a684943e95af087c9e86 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Wed, 19 Apr 2017 21:18:11 -0300 Subject: Import Github releases --- lib/github/import.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/github/import.rb') diff --git a/lib/github/import.rb b/lib/github/import.rb index 12f4dbc9e43..4ef0ac3e40c 100644 --- a/lib/github/import.rb +++ b/lib/github/import.rb @@ -255,6 +255,33 @@ module Github end end + def fetch_releases + url = "/repos/#{repo}/releases" + + while url + response = Github::Client.new(options).get(url) + + response.body.each do |raw| + representation = Github::Representation::Release.new(raw) + next unless representation.valid? + + release = ::Release.find_or_initialize_by(project_id: project.id, tag: representation.tag) + next unless relese.new_record? + + begin + release.description = representation.description + release.created_at = representation.created_at + release.updated_at = representation.updated_at + release.save!(validate: false) + rescue => e + error(:release, representation.url, e.message) + end + end + + url = response.rels[:next] + end + end + def restore_source_branch(pull_request) repository.create_branch(pull_request.source_branch_name, pull_request.source_branch_sha) end -- cgit v1.2.1