Skip to content

Commit

Permalink
Merge pull request ManageIQ#14 from Fryguy/fetch_released_migrations_…
Browse files Browse the repository at this point in the history
…via_github_api

Fetch released migrations via the GitHub API
  • Loading branch information
chessbyte committed Jun 23, 2017
2 parents 15d7a90 + bd5ce03 commit cad19b8
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions lib/tasks_private/spec.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cad19b8

Please sign in to comment.