<commit_before>module CapistranoDeploy
  module Environment
    def self.load_into(configuration)
      configuration.load do

        set(:environment_file) { ".env" }

        namespace :environment do

          namespace :servers do
            desc "Copy ENV file from remote git repository to your staging/production servers"
            task :fetch_config, :roles => :app, :except => {:no_release => true} do
              path_to_new_env = File.join deploy_to, "tmp", "env_config", app_name, ".env.#{current_stage}"
              path_to_old_env = File.join deploy_to, environment_file

              run "rm -rf #{deploy_to}/tmp/env_config && git clone -n #{environment_repository} --depth 1 #{deploy_to}/tmp/env_config"
              run "cd #{deploy_to}/tmp/env_config && git checkout HEAD #{app_name}/.env.#{current_stage}"

              lines_changed = capture("diff #{path_to_new_env} #{path_to_old_env} | wc -l").chomp.to_i

              if lines_changed > 0 && /^y/i =~ Capistrano::CLI.ui.ask("Do you wish to override the existing #{environment_file} file (y/n)? ")
                run "cp #{path_to_new_env}  #{path_to_old_env}"
              else
                puts "No config changes found (or you said 'No')"
              end

            end

          end

          namespace :local do
            desc "Fetch ENV file from remote git repository to your local machine"
            task :fetch_config do
              raise "Not yet implemented"
            end
          end

          after 'deploy:setup', 'environment:servers:fetch_config'

        end

      end
    end
  end
end<commit_msg>Ask for .env override at the beginning of task<commit_after>module CapistranoDeploy
  module Environment
    def self.load_into(configuration)
      configuration.load do

        set(:environment_file) { ".env" }

        namespace :environment do

          namespace :servers do
            desc "Copy ENV file from remote git repository to your staging/production servers"
            task :fetch_config, :roles => :app, :except => {:no_release => true} do

              if /^y/i =~ Capistrano::CLI.ui.ask("Do you wish to override the existing #{environment_file} file (y/n)? ")

              path_to_new_env = File.join deploy_to, "tmp", "env_config", app_name, ".env.#{current_stage}"
              path_to_old_env = File.join deploy_to, environment_file

              run "rm -rf #{deploy_to}/tmp/env_config && git clone -n #{environment_repository} --depth 1 #{deploy_to}/tmp/env_config"
              run "cd #{deploy_to}/tmp/env_config && git checkout HEAD #{app_name}/.env.#{current_stage}"
              run "cp #{path_to_new_env}  #{path_to_old_env}"
              else
                puts "Config not changed"
              end
            end

          end

          namespace :local do
            desc "Fetch ENV file from remote git repository to your local machine"
            task :fetch_config do
              raise "Not yet implemented"
            end
          end

          after 'deploy:setup', 'environment:servers:fetch_config'

        end

      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09552715654952076, 'fraction_numerical': 0.0009584664536741214, 'mean_word_length': 2.1030723488602576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '507414', 'n_tokens_mistral': 899, 'n_tokens_neox': 864, 'n_words': 262}