-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display the deployed version in the application footer (#1670)
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
revisions_logfile = Rails.root.join("..", "..", "revisions.log") | ||
|
||
GIT_SHA = | ||
if File.exist?(revisions_logfile) | ||
`tail -1 #{revisions_logfile}`.chomp.split(" ")[3].gsub(/\)$/, "") | ||
elsif Rails.env.development? || Rails.env.test? | ||
`git rev-parse HEAD`.chomp | ||
else | ||
"Unknown SHA" | ||
end | ||
|
||
BRANCH = | ||
if File.exist?(revisions_logfile) | ||
`tail -1 #{revisions_logfile}`.chomp.split(" ")[1] | ||
elsif Rails.env.development? || Rails.env.test? | ||
`git rev-parse --abbrev-ref HEAD`.chomp | ||
else | ||
"Unknown branch" | ||
end | ||
|
||
LAST_DEPLOYED = | ||
if File.exist?(revisions_logfile) | ||
deployed = `tail -1 #{revisions_logfile}`.chomp.split(" ")[7] | ||
Date.parse(deployed).strftime("%d %B %Y") | ||
else | ||
"Not in deployed environment" | ||
end |