<commit_before>module Heroku::Deploy
  class Delta
    def self.calcuate_from(from, to)
      new(from, to)
    end

    attr_accessor :from, :to, :git

    def initialize(from, to)
      @from = from
      @to   = to
      @git  = Git.new
    end

    def diff
      @diff ||= git.diff :from => from, :to => to, :folder => "db/migrate"
    end

    def has_migrations?
      diff.match(/ActiveRecord::Migration/)
    end

    def has_unsafe_migrations?
      diff.match(/change_column|change_table|drop_table|remove_column|remove_index|rename_column|execute/)
    end
  end
end
<commit_msg>Added asset checking to the delta calculator.<commit_after>module Heroku::Deploy
  class Delta
    def self.calcuate_from(from, to)
      new(from, to)
    end

    attr_accessor :from, :to, :git

    def initialize(from, to)
      @from = from
      @to   = to
      @git  = Git.new
    end

    def diff(folders)
      git.diff :from => from, :to => to, :folder => folders.join(" ")
    end

    def has_asset_changes?
      folders_that_could_have_changes = %w(app/assets lib/assets vendor/assets Gemfile.lock)

      diff(folders_that_could_have_changes).match /diff/
    end

    def has_migrations?
      migrations_diff.match /ActiveRecord::Migration/
    end

    def has_unsafe_migrations?
      migrations_diff.match /change_column|change_table|drop_table|remove_column|remove_index|rename_column|execute/
    end

    private

    def migrations_diff
      diff %w(db/migrate)
    end
  end
end

{'fraction_non_alphanumeric': 0.09819639278557114, 'fraction_numerical': 0.0, 'mean_word_length': 2.782828282828283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7430187', 'n_tokens_mistral': 512, 'n_tokens_neox': 506, 'n_words': 113}