module MigrationInvestigation

Constants

VERSION

Public Class Methods

pending_migrations?(stage, new_sha, options={}) click to toggle source
# File lib/migration_investigation.rb, line 5
def pending_migrations?(stage, new_sha, options={})
  old_sha = latest_stage_sha stage
  return true if old_sha.nil?

  change_count(old_sha, new_sha, build_interesting_paths(options.fetch(:additional_paths, [])), options[:skip_filepath_pattern]) != 0
end

Private Class Methods

build_interesting_paths(additional_paths) click to toggle source
# File lib/migration_investigation.rb, line 25
def build_interesting_paths(additional_paths)
  interesting_paths = ["db/migrate/"]
  interesting_paths << additional_paths
  interesting_paths.flatten
end
change_count(old_sha, new_sha, interesting_paths, skip_filepath_pattern) click to toggle source
# File lib/migration_investigation.rb, line 19
def change_count(old_sha, new_sha, interesting_paths, skip_filepath_pattern)
  cmd = "git diff --name-only #{old_sha} #{new_sha} #{interesting_paths.join(" ")}"
  changes = `#{cmd}`
  changes.split("\n").reject { |l| l.length == 0 }.reject { |l| skip_filepath_pattern && l =~ skip_filepath_pattern }.length
end
latest_stage_sha(stage) click to toggle source
# File lib/migration_investigation.rb, line 14
def latest_stage_sha(stage)
  latest_tag = AutoTagger::Base.new({}).refs_for_stage(stage).last
  latest_tag.sha if latest_tag
end