Module: AppRevision

Defined in:
lib/app_revision.rb,
lib/app_revision/version.rb

Overview

Returns the current application git commit SHA. Will look first in the APP_REVISION environment variable, then in the REVISION file written by Capsitrano, then in the Git history and lastly will return ‘unknown’ will be returned

Constant Summary collapse

ENV_VARS =
[
  'APP_REVISION', # As used by Appsignal et al
  'HEROKU_SLUG_COMMIT', # As is available in https://devcenter.heroku.com/articles/dyno-metadata
  'SOURCE_VERSION', # As defined in https://devcenter.heroku.com/changelog-items/630
  'TRAVIS_COMMIT', # As per https://docs.travis-ci.com/user/environment-variables/
]
VERSION =
"0.2.1"

Class Method Summary collapse

Class Method Details

.currentObject

Calls ‘determine_current` with memoization.



15
16
17
# File 'lib/app_revision.rb', line 15

def self.current
  @current ||= determine_current
end

.determine_currentObject

Performs version detection in the following order: APP_REVISION -> REVISION file -> git -> “unknown” and returns the current commit/revision SHA as a String



22
23
24
25
# File 'lib/app_revision.rb', line 22

def self.determine_current
  detected_rev_str = read_from_env || read_from_revision_file || determine_from_git_rev || unknown_revision
  up_to_newline(detected_rev_str)
end