Skip to content

Commit e31532f

Browse files
authored
Merge pull request #78 from pulibrary/version_in_footer
Display the application version number in the footer
2 parents 33e68e1 + 705d44c commit e31532f

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

app/assets/stylesheets/application.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@
1313
*= require_tree .
1414
*= require_self
1515
*/
16+
17+
.deployment-version {
18+
color: gray;
19+
float: right;
20+
}

app/views/layouts/application.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,8 @@
4040
<div class="lux">
4141
<library-footer></library-footer>
4242
</div>
43+
<div class="deployment-version copyright" >
44+
Version <span title="<%= GIT_SHA %>"><%= BRANCH %> last updated <%= LAST_DEPLOYED %>.</span>
45+
</div>
4346
</body>
4447
</html>

config/initializers/git_sha.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: true
2+
3+
revisions_logfile = Rails.root.join("..", "..", "revisions.log")
4+
5+
GIT_SHA =
6+
if File.exist?(revisions_logfile)
7+
`tail -1 #{revisions_logfile}`.chomp.split(" ")[3].gsub(/\)$/, "")
8+
elsif Rails.env.development? || Rails.env.test?
9+
`git rev-parse HEAD`.chomp
10+
else
11+
"Unknown SHA"
12+
end
13+
14+
BRANCH =
15+
if File.exist?(revisions_logfile)
16+
`tail -1 #{revisions_logfile}`.chomp.split(" ")[1]
17+
elsif Rails.env.development? || Rails.env.test?
18+
`git rev-parse --abbrev-ref HEAD`.chomp
19+
else
20+
"Unknown branch"
21+
end
22+
23+
LAST_DEPLOYED =
24+
if File.exist?(revisions_logfile)
25+
deployed = `tail -1 #{revisions_logfile}`.chomp.split(" ")[7]
26+
Date.parse(deployed).strftime("%d %B %Y")
27+
else
28+
"Not in deployed environment"
29+
end

0 commit comments

Comments
 (0)