From bd5ce03eb8a80adc913ee0d5f2a02a3f7f9f0ca7 Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Tue, 20 Jun 2017 22:25:59 -0400 Subject: [PATCH] Fetch released migrations via the GitHub API This reverts the released migrations to using the GitHub API as was done in 9fba1a424a3ca3b1a1f534b6ab623527e9fd33d5. The concern for the GitHub rate limits in 9568c7aad74c1d5a58d88f04fe824f90fb883293 is no longer a problem now that migrations are in their own repo which should have much less churn, unlike the main manageiq repo where the migrations would run on *every* PR. Fixes #6 --- lib/tasks_private/spec.rake | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/tasks_private/spec.rake b/lib/tasks_private/spec.rake index 85b6861d8..4fb8ac3a4 100644 --- a/lib/tasks_private/spec.rake +++ b/lib/tasks_private/spec.rake @@ -30,22 +30,15 @@ class SetupReleasedMigrations private def released_migrations - return [] unless system(fetch_command) - files = `git ls-tree -r --name-only #{TEST_BRANCH} db/migrate/` - return [] unless $?.success? + require 'net/http' + json = Net::HTTP.get(URI("https://api.github.com/repos/ManageIQ/manageiq/contents/db/migrate?ref=#{RELEASED_BRANCH}")) - migrations = files.split.map do |path| - filename = path.split("/")[-1] + migrations = JSON.parse(json).map do |h| + filename = h["path"].split("/")[-1] filename.split('_')[0] - end + end.sort # eliminate any non-timestamp entries migrations.keep_if { |timestamp| timestamp =~ /\d+/ } - ensure - `git branch -D #{TEST_BRANCH}` - end - - def fetch_command - "git fetch #{'--depth=1 ' if ENV['CI']}http://github.com/ManageIQ/manageiq.git refs/heads/#{RELEASED_BRANCH}:#{TEST_BRANCH}" end end