Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch released migrations via the GitHub API #14

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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