Class: Airbrake::Filters::GitLastCheckoutFilter Private

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/airbrake-ruby/filters/git_last_checkout_filter.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Attaches git checkout info to ‘context`. The info includes:

* username
* email
* revision
* time

This information is used to track deploys automatically.

Since:

  • v2.12.0

Constant Summary collapse

MIN_HEAD_COLS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Returns least possible amount of columns in git’s ‘logs/HEAD` file (checkout information is omitted).

Returns:

  • (Integer)

    least possible amount of columns in git’s ‘logs/HEAD` file (checkout information is omitted)

Since:

  • v2.12.0

6

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#logger

Constructor Details

#initialize(root_directory) ⇒ GitLastCheckoutFilter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of GitLastCheckoutFilter.

Parameters:

  • root_directory (String)

Since:

  • v2.12.0



26
27
28
29
30
31
# File 'lib/airbrake-ruby/filters/git_last_checkout_filter.rb', line 26

def initialize(root_directory)
  @git_path = File.join(root_directory, '.git')
  @weight = 116
  @last_checkout = nil
  @deploy_username = ENV.fetch('AIRBRAKE_DEPLOY_USERNAME', nil)
end

Instance Attribute Details

#weightInteger (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)

Since:

  • v2.12.0



17
18
19
# File 'lib/airbrake-ruby/filters/git_last_checkout_filter.rb', line 17

def weight
  @weight
end

Instance Method Details

#call(notice) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

This is a mandatory method required by any filter integrated with FilterChain.

Parameters:

  • notice (Notice)

    the notice to be filtered

See Also:

Since:

  • v2.12.0



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/airbrake-ruby/filters/git_last_checkout_filter.rb', line 34

def call(notice)
  return if notice[:context].key?(:lastCheckout)

  if @last_checkout
    notice[:context][:lastCheckout] = @last_checkout
    return
  end

  return unless File.exist?(@git_path)
  return unless (checkout = last_checkout)

  notice[:context][:lastCheckout] = checkout
end