<commit_before># # Modules: AppSignal
# Adds settings and tasks for notifying AppSignal.
#
#     require 'mina/appsignal'
#
# ## Usage example
#     require 'mina/appsignal'
#
#     # this is your 'post_server_item' token for your project
#     set :appsignal_api_key, 'appsignal-api-key-goes-here'
#
#     task :deploy do
#       deploy do
#         ...
#
#         to :launch do
#           ...
#           invoke :'appsignal:notify'
#         end
#       end
#     end

require 'mina/rails'
require 'json'
require 'shellwords'

# ## Settings
# Any and all of these settings can be overriden in your `deploy.rb`.

# ### appsignal_api_key
# Sets the push api key for your AppSignal account.  Will be read from 
# config/appsignal.yml, or the APPSIGNAL_PUSH_API_KEY if not set.  Required.
set_default :appsignal_api_key, nil

# ### appsignal_app_name
# Sets the name of the app being deployed.  Will be read from 
# config/appsignal.yml, or the APPSIGNAL_APP_NAME if not set.  Required.
set_default :appsignal_app_name, nil

# ### appsignal_local_username
# Sets the name of the user who deployed.  Defaults to `whoami`.  Optional.
set_default :appsignal_local_username, %x[whoami].strip rescue nil

# ### appsignal_notification_debug
# If true, enables verbosity in the notification to help debug issues.  Defaults to false.
set_default :appsignal_notification_debug, false

namespace :appsignal do

  desc 'Notifies AppSignal of your deployment'
  task notify: :environment do

    api_key = appsignal_api_key
    api_key ||= Mina::AppSignal.from_config(rails_env, 'push_api_key')
    api_key ||= ENV['APPSIGNAL_PUSH_API_KEY']
    unless api_key
      print_error '`:appsignal_api_key` must be defined to notify'
      exit
    end

    app_name = appsignal_app_name
    app_name ||= Mina::AppSignal.from_config(rails_env, 'name')
    app_name ||= ENV['APPSIGNAL_APP_NAME']
    unless app_name
      print_error '`:appsignal_app_name` must be defined to notify'
      exit
    end

    unless branch? || commit?
      print_error 'Must define either `:branch` or `:commit`'
      exit
    end

    revision = commit? ? commit : %x[git rev-parse #{branch}].strip

    body = { revision: revision }
    body[:repository] = branch if branch?
    body[:user] = appsignal_local_username.shellescape if appsignal_local_username

    silent = appsignal_notification_debug ? '-v' : '-s -o /dev/null'
    script = [%Q(curl #{silent} -X POST)]
    script << %Q(-d '#{body.to_json}')
    script << %Q("https://push.appsignal.com/1/markers?api_key=#{api_key}&name=#{app_name}&environment=#{rails_env}")

    queue! 'echo "-----> Notifying AppSignal of deployment"'
    queue script.join(' ')

  end

end
<commit_msg>Update to mina 1.0 syntax<commit_after># # Modules: AppSignal
# Adds settings and tasks for notifying AppSignal.
#
#     require 'mina/appsignal'
#
# ## Usage example
#     require 'mina/appsignal'
#
#     # this is your 'post_server_item' token for your project
#     set :appsignal_api_key, 'appsignal-api-key-goes-here'
#
#     task :deploy do
#       deploy do
#         ...
#
#         to :launch do
#           ...
#           invoke :'appsignal:notify'
#         end
#       end
#     end

require 'mina/rails'
require 'json'
require 'shellwords'

# ## Settings
# Any and all of these settings can be overriden in your `deploy.rb`.

# ### appsignal_api_key
# Sets the push api key for your AppSignal account.  Will be read from
# config/appsignal.yml, or the APPSIGNAL_PUSH_API_KEY if not set.  Required.
set :appsignal_api_key, nil

# ### appsignal_app_name
# Sets the name of the app being deployed.  Will be read from
# config/appsignal.yml, or the APPSIGNAL_APP_NAME if not set.  Required.
set :appsignal_app_name, nil

# ### appsignal_local_username
# Sets the name of the user who deployed.  Defaults to `whoami`.  Optional.
set :appsignal_local_username, %x[whoami].strip rescue nil

# ### appsignal_notification_debug
# If true, enables verbosity in the notification to help debug issues.  Defaults to false.
set :appsignal_notification_debug, false

namespace :appsignal do

  desc 'Notifies AppSignal of your deployment'
  task notify: :environment do
    api_key = fetch(:appsignal_api_key)
    api_key ||= Mina::AppSignal.from_config(rails_env, 'push_api_key')
    api_key ||= ENV['APPSIGNAL_PUSH_API_KEY']
    unless api_key
      print_error '`:appsignal_api_key` must be defined to notify'
      exit
    end

    app_name = fetch(:appsignal_app_name)
    app_name ||= Mina::AppSignal.from_config(rails_env, 'name')
    app_name ||= ENV['APPSIGNAL_APP_NAME']
    unless app_name
      print_error '`:appsignal_app_name` must be defined to notify'
      exit
    end

    unless set?(:branch) || set?(:commit)
      print_error 'Must define either `:branch` or `:commit`'
      exit
    end

    revision = set?(:commit) ? fetch(:commit) : %x[git rev-parse #{fetch(:branch)}].strip

    body = { revision: revision }
    body[:repository] = fetch(:branch) if set?(:branch)
    body[:user] = fetch(:appsignal_local_username).shellescape if set?(:appsignal_local_username)

    silent = fetch(:appsignal_notification_debug) ? '-v' : '-s -o /dev/null'
    script = [%Q(curl #{silent} -X POST)]
    script << %Q(-d '#{body.to_json}')
    script << %Q("https://push.appsignal.com/1/markers?api_key=#{api_key}&name=#{app_name}&environment=#{rails_env}")

    comment %{Notifying AppSignal of deployment}
    command %[#{script.join(' ')}]
  end

end

{'fraction_non_alphanumeric': 0.11515262292085542, 'fraction_numerical': 0.0007311277645768598, 'mean_word_length': 3.5335542667771334, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '786502', 'n_tokens_mistral': 1826, 'n_tokens_neox': 1789, 'n_words': 499}