<commit_before>require "diffy"

Capistrano::Configuration.instance(true).load do
  #
  # Hooks
  #
  before "deploy:finalize_update", "deploy:confirm_updated"

  #
  # Dependencies
  #
  depend(:remote, :command, "shasum")
  depend(:local, :command, "shasum")

  #
  # Tasks
  #
  namespace :deploy do
    task :confirm_updated, :except => { :no_release => true } do
      files = ["Gemfile", "Gemfile.lock"]
      files += capture("cd #{latest_release} && find config -type f").to_s.split

      # Ignore subversion files.
      files.reject! { |file| file =~ %r{.svn(/|$)} }

      # For the development environment, we might be deploying on top of an
      # existing sandbox. So ignore any files that get generated dynamically as
      # part of the deployment process.
      template_files = files.select { |file| file =~ /\.erb$/ }
      parsed_template_files = template_files.collect { |file| file.gsub(/\.erb$/, "") }
      files -= parsed_template_files
      files.reject! { |file| file =~ %r{config/deployed.yml$} }

      files.sort!

      local_checksum = run_locally("shasum -a 256 #{files.join(" ")}").strip.gsub(/[\r\n]+/, "\n")
      remote_checksum = capture("cd #{latest_release} && shasum -a 256 #{files.join(" ")}").strip.gsub(/[\r\n]+/, "\n")

      if(local_checksum != remote_checksum)
        diff = Diffy::Diff.new(local_checksum, remote_checksum, :diff => ["-U 0"])
        raise Capistrano::Error, <<-eos

##### ERROR: MISMATCHED DEPLOYMENT RESOURCES #####

The deployment scripts or resources on the destination server do not match the
versions present locally. Please make sure your working copy is up to date or
any pending commits to deployment resource files are commited.

The following files differ:

#{diff}
        eos
      end
    end
  end
end
<commit_msg>Ignore git files when looking for mismatched resources.<commit_after>require "diffy"

Capistrano::Configuration.instance(true).load do
  #
  # Hooks
  #
  before "deploy:finalize_update", "deploy:confirm_updated"

  #
  # Dependencies
  #
  depend(:remote, :command, "shasum")
  depend(:local, :command, "shasum")

  #
  # Tasks
  #
  namespace :deploy do
    task :confirm_updated, :except => { :no_release => true } do
      files = ["Gemfile", "Gemfile.lock"]
      files += capture("cd #{latest_release} && find config -type f").to_s.split

      # Ignore SCM files.
      files.reject! { |file| file =~ %r{.(svn|git)(/|$)} }

      # For the development environment, we might be deploying on top of an
      # existing sandbox. So ignore any files that get generated dynamically as
      # part of the deployment process.
      template_files = files.select { |file| file =~ /\.erb$/ }
      parsed_template_files = template_files.collect { |file| file.gsub(/\.erb$/, "") }
      files -= parsed_template_files
      files.reject! { |file| file =~ %r{config/deployed.yml$} }

      files.sort!

      local_checksum = run_locally("shasum -a 256 #{files.join(" ")}").strip.gsub(/[\r\n]+/, "\n")
      remote_checksum = capture("cd #{latest_release} && shasum -a 256 #{files.join(" ")}").strip.gsub(/[\r\n]+/, "\n")

      if(local_checksum != remote_checksum)
        diff = Diffy::Diff.new(local_checksum, remote_checksum, :diff => ["-U 0"])
        raise Capistrano::Error, <<-eos

##### ERROR: MISMATCHED DEPLOYMENT RESOURCES #####

The deployment scripts or resources on the destination server do not match the
versions present locally. Please make sure your working copy is up to date or
any pending commits to deployment resource files are commited.

The following files differ:

#{diff}
        eos
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.1419532324621733, 'fraction_numerical': 0.0038514442916093533, 'mean_word_length': 3.2328288707799766, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6031576', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1142, 'n_words': 333}