Class: Airbrake::Filters::GitRepositoryFilter Private
- Inherits:
-
Object
- Object
- Airbrake::Filters::GitRepositoryFilter
- Defined in:
- lib/airbrake-ruby/filters/git_repository_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 repository URL to ‘context`.
Instance Attribute Summary collapse
- #weight ⇒ Integer readonly private
Instance Method Summary collapse
- #attach_repository(notice) ⇒ Object private
-
#call(notice) ⇒ void
private
This is a mandatory method required by any filter integrated with FilterChain.
-
#initialize(root_directory) ⇒ GitRepositoryFilter
constructor
private
A new instance of GitRepositoryFilter.
Constructor Details
#initialize(root_directory) ⇒ GitRepositoryFilter
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 GitRepositoryFilter.
11 12 13 14 15 16 |
# File 'lib/airbrake-ruby/filters/git_repository_filter.rb', line 11 def initialize(root_directory) @git_path = File.join(root_directory, '.git') @repository = nil @git_version = detect_git_version @weight = 116 end |
Instance Attribute Details
#weight ⇒ Integer (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.
8 9 10 |
# File 'lib/airbrake-ruby/filters/git_repository_filter.rb', line 8 def weight @weight end |
Instance Method Details
#attach_repository(notice) ⇒ Object
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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/airbrake-ruby/filters/git_repository_filter.rb', line 25 def attach_repository(notice) if @repository notice[:context][:repository] = @repository return end return unless File.exist?(@git_path) return unless @git_version @repository = if @git_version >= Gem::Version.new('2.7.0') `cd #{@git_path} && git config --get remote.origin.url`.chomp else "`git remote get-url` is unsupported in git #{@git_version}. " \ 'Consider an upgrade to 2.7+' end return unless @repository notice[:context][:repository] = @repository end |
#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.
19 20 21 22 23 |
# File 'lib/airbrake-ruby/filters/git_repository_filter.rb', line 19 def call(notice) return if notice[:context].key?(:repository) attach_repository(notice) end |