<commit_before>require 'git'
require 'octokit'
require 'mail'

Capistrano::Configuration.instance(:must_exist).load do
  after   "deploy",               "send_diff:send"
  before  "send_diff:send",       "send_diff:mail_setup"
  before  "send_diff:mail_setup", "send_diff:get_diff"
  
  namespace :send_diff do
    
    def public_repo
      repo_name = "#{fetch(:repository).scan(/:(.*)\.git/).last.first}"
      tags = Octokit.tags(repo_name)
      if tags.count > 1
        to = tags.first
        from = tags[1]
        git_link = "https://www.github.com/#{repo_name}/compare/#{from.commit.sha}...#{to.commit.sha}"
        run "curl -i http://git.io -F \"url=#{git_link}\"" do |channel, stream, data|
          if data.include? "Location:"
            data.scan(/Location:\s+(.*)/).last.first
          end
        end
      end
    end
    
    def private_repo
      git = Git.open(Dir.pwd.to_s)
      commits = Array.new
      git.log.each {|l| commits.push l.sha }
      git.diff(commits.first(2).last, commits.first(2).first).to_s
    end
    
    desc "Gets git diff"
    task :get_diff do
      begin
        set :git_diff, public_repo
      rescue
        set :git_diff, private_repo
      end
    end
    
    desc "Sends git diff"
    task :send do
      body_message = fetch(:git_diff, "No changes in #{fetch(:app_title, 'this project')}")
      mail = Mail.new do
        from    '<EMAIL>'
        body    body_message
      end
      mail[:subject] = "Recent changes for #{fetch(:app_title, 'this project')}"
      mail[:to] = fetch :recipient, ""
      mail.deliver! unless mail[:to].to_s.empty?
    end
    
    desc "Sets up settings for mail"
    task :mail_setup do
      Mail.defaults do
        delivery_method :smtp, { 
          :openssl_verify_mode => OpenSSL::SSL::VERIFY_NONE, 
          :address => 'mail.library.nyu.edu',
          :port => '25',
          :enable_starttls_auto => true
        }
      end
    end
  end
end<commit_msg>Send is the name of another task<commit_after>require 'git'
require 'octokit'
require 'mail'

Capistrano::Configuration.instance(:must_exist).load do
  after   "deploy",               "send_diff:send_diff"
  before  "send_diff:send_diff",       "send_diff:mail_setup"
  before  "send_diff:mail_setup", "send_diff:get_diff"
  
  namespace :send_diff do
    
    def public_repo
      repo_name = "#{fetch(:repository).scan(/:(.*)\.git/).last.first}"
      tags = Octokit.tags(repo_name)
      if tags.count > 1
        to = tags.first
        from = tags[1]
        git_link = "https://www.github.com/#{repo_name}/compare/#{from.commit.sha}...#{to.commit.sha}"
        run "curl -i http://git.io -F \"url=#{git_link}\"" do |channel, stream, data|
          if data.include? "Location:"
            data.scan(/Location:\s+(.*)/).last.first
          end
        end
      end
    end
    
    def private_repo
      git = Git.open(Dir.pwd.to_s)
      commits = Array.new
      git.log.each {|l| commits.push l.sha }
      git.diff(commits.first(2).last, commits.first(2).first).to_s
    end
    
    desc "Gets git diff"
    task :get_diff do
      begin
        set :git_diff, public_repo
      rescue
        set :git_diff, private_repo
      end
    end
    
    desc "Sends git diff"
    task :send_diff do
      body_message = fetch(:git_diff, "No changes in #{fetch(:app_title, 'this project')}")
      mail = Mail.new do
        from    '<EMAIL>'
        body    body_message
      end
      mail[:subject] = "Recent changes for #{fetch(:app_title, 'this project')}"
      mail[:to] = fetch :recipient, ""
      mail.deliver! unless mail[:to].to_s.empty?
    end
    
    desc "Sets up settings for mail"
    task :mail_setup do
      Mail.defaults do
        delivery_method :smtp, { 
          :openssl_verify_mode => OpenSSL::SSL::VERIFY_NONE, 
          :address => 'mail.library.nyu.edu',
          :port => '25',
          :enable_starttls_auto => true
        }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13256048387096775, 'fraction_numerical': 0.0030241935483870967, 'mean_word_length': 2.1575178997613365, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '3079925', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1320, 'n_words': 295}