Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for heroku dyno metadata env variables #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ Unfortunately Heroku [removes](https://devcenter.heroku.com/articles/slug-compil
the .git directory during slug compilation which doesn't make it possible to
view the current deployed SHA or branch.

The one workaround is to set the GIT_SHA and GIT_BRANCH ENV variables within
One workaround is to set the GIT_SHA and GIT_BRANCH ENV variables within
your deploy process.

An alternative workaround is to use the runtime dyno metadata lab flag:

$ heroku labs:enable runtime-dyno-metadata -a <app name>

Then, Peek can display the current Heroku release and sha.

## Contributing

1. Fork it
Expand Down
8 changes: 5 additions & 3 deletions lib/peek/views/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ def nwo?
!!@nwo
end

# Fetch the current branch name.
# Fetch the current branch name or heroku release version.
def branch_name
@branch_name ||= ENV['GIT_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.chomp
@branch_name ||= ENV['GIT_BRANCH'] || ENV['HEROKU_RELEASE_VERSION']
@branch_name ||= `git rev-parse --abbrev-ref HEAD`.chomp
end

# Fetch the current sha if one isn't present.
def sha
@sha ||= ENV['GIT_SHA'] || `git rev-parse HEAD`.chomp
@sha ||= ENV['HEROKU_SLUG_COMMIT'] || ENV['GIT_SHA']
@sha ||= `git rev-parse HEAD`.chomp
end

def short_sha
Expand Down