Skip to content

Commit

Permalink
Merge pull request #78 from pulibrary/version_in_footer
Browse files Browse the repository at this point in the history
Display the application version number in the footer
  • Loading branch information
jrgriffiniii authored Sep 22, 2021
2 parents 33e68e1 + 705d44c commit e31532f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@
*= require_tree .
*= require_self
*/

.deployment-version {
color: gray;
float: right;
}
3 changes: 3 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
<div class="lux">
<library-footer></library-footer>
</div>
<div class="deployment-version copyright" >
Version <span title="<%= GIT_SHA %>"><%= BRANCH %> last updated <%= LAST_DEPLOYED %>.</span>
</div>
</body>
</html>
29 changes: 29 additions & 0 deletions config/initializers/git_sha.rb
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

0 comments on commit e31532f

Please sign in to comment.