Class: Sentry::ReleaseDetector Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sentry/release_detector.rb

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.

Class Method Summary collapse

Class Method Details

.detect_release(project_root:, running_on_heroku:) ⇒ 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.

[View source]

7
8
9
10
11
12
# File 'lib/sentry/release_detector.rb', line 7

def detect_release(project_root:, running_on_heroku:)
  detect_release_from_env ||
  detect_release_from_git ||
  detect_release_from_capistrano(project_root) ||
  detect_release_from_heroku(running_on_heroku)
end

.detect_release_from_capistrano(project_root) ⇒ 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.

[View source]

19
20
21
22
23
24
25
26
27
28
# File 'lib/sentry/release_detector.rb', line 19

def detect_release_from_capistrano(project_root)
  revision_file = File.join(project_root, "REVISION")
  revision_log = File.join(project_root, "..", "revisions.log")

  if File.exist?(revision_file)
    File.read(revision_file).strip
  elsif File.exist?(revision_log)
    File.open(revision_log).to_a.last.strip.sub(/.*as release ([0-9]+).*/, '\1')
  end
end

.detect_release_from_envObject

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.

[View source]

34
35
36
# File 'lib/sentry/release_detector.rb', line 34

def detect_release_from_env
  ENV["SENTRY_RELEASE"]
end

.detect_release_from_gitObject

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.

[View source]

30
31
32
# File 'lib/sentry/release_detector.rb', line 30

def detect_release_from_git
  Sentry.sys_command("git rev-parse HEAD") if File.directory?(".git")
end

.detect_release_from_heroku(running_on_heroku) ⇒ 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.

[View source]

14
15
16
17
# File 'lib/sentry/release_detector.rb', line 14

def detect_release_from_heroku(running_on_heroku)
  return unless running_on_heroku
  ENV["HEROKU_SLUG_COMMIT"]
end