Class: Airbrake::Filters::GitRevisionFilter Private

Inherits:
Object
  • Object
show all
Defined in:
lib/airbrake-ruby/filters/git_revision_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 current git revision to ‘context`.

Since:

  • v2.11.0

Constant Summary collapse

PREFIX =

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:

  • (String)

Since:

  • v2.11.0

'ref: '.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_directory) ⇒ GitRevisionFilter

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 GitRevisionFilter.

Parameters:

  • root_directory (String)

Since:

  • v2.11.0



14
15
16
17
18
# File 'lib/airbrake-ruby/filters/git_revision_filter.rb', line 14

def initialize(root_directory)
  @git_path = File.join(root_directory, '.git')
  @revision = nil
  @weight = 116
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.11.0



8
9
10
# File 'lib/airbrake-ruby/filters/git_revision_filter.rb', line 8

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.11.0



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/airbrake-ruby/filters/git_revision_filter.rb', line 21

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

  if @revision
    notice[:context][:revision] = @revision
    return
  end

  return unless File.exist?(@git_path)

  @revision = find_revision
  return unless @revision

  notice[:context][:revision] = @revision
end