Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/raven/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ def initialize
self.sanitize_fields = []
self.sanitize_credit_cards = true
self.environments = []

self.release = ENV['HEROKU_SLUG_COMMIT']

if self.release.nil? || self.release.empty?
self.release = `git rev-parse --short HEAD`.strip rescue nil
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call on git not existing on the system. I wrapped the sys call in a rescue: this will fail gracefully if the user doesn't have git installed, or if the current directory is not a git repo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess in that case release will be nil. Anything else we can fall back to? I guess not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that's right: if the user isn't on heroku, and isn't using git, then release == nil. Although not idea, I think this solution will auto-tag errors with commit in the majority of cases.

end

if (self.release.nil? || self.release.empty?) && File.exists?('REVISION')
self.release = File.read('REVISION').strip
end
end

def server=(value)
Expand Down