mirror of
https://github.com/SrIzan10/hc-harbor.git
synced 2026-05-01 10:45:21 +00:00
Link to current commit in footer
This commit is contained in:
@@ -32,7 +32,8 @@
|
||||
<footer>
|
||||
<div class="container">
|
||||
<p>
|
||||
Build <%= Rails.application.config.git_version %> from <%= time_ago_in_words(Rails.application.config.server_start_time) %> ago.
|
||||
Build <%= link_to Rails.application.config.git_version, Rails.application.config.commit_link %>
|
||||
from <%= time_ago_in_words(Rails.application.config.server_start_time) %> ago.
|
||||
<%= pluralize(Heartbeat.cached_recent_count, 'heartbeat') %> in the last 24 hours.
|
||||
(DB: <%= pluralize(QueryCount::Counter.counter, "query") %>, <%= QueryCount::Counter.counter_cache %> cached)
|
||||
(CACHE: <%= cache_stats[:hits] %> hits, <%= cache_stats[:misses] %> misses)
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
# Get the first 6 characters of the current git commit hash
|
||||
git_hash = ENV["SOURCE_COMMIT"]&.[](0..5) ||
|
||||
`git rev-parse HEAD`.strip[0..5] rescue "unknown"
|
||||
git_hash = ENV["SOURCE_COMMIT"] || `git rev-parse HEAD` rescue "unknown"
|
||||
|
||||
commit_link = git_hash != "unknown" ? "https://github.com/hackclub/harbor/commit/#{git_hash}" : nil
|
||||
|
||||
short_hash = git_hash[0..7]
|
||||
|
||||
commit_count = `git rev-list --count HEAD`.strip rescue 0
|
||||
|
||||
# Check if there are any uncommitted changes
|
||||
is_dirty = `git status --porcelain`.strip.length > 0 rescue false
|
||||
|
||||
# Append "-dirty" if there are uncommitted changes
|
||||
version = is_dirty ? "#{git_hash}-dirty" : git_hash
|
||||
version = is_dirty ? "#{short_hash}-dirty" : short_hash
|
||||
|
||||
# Store server start time
|
||||
Rails.application.config.server_start_time = Time.current
|
||||
|
||||
# Store the version
|
||||
Rails.application.config.git_version = version
|
||||
Rails.application.config.git_commit_count = commit_count
|
||||
Rails.application.config.commit_link = commit_link
|
||||
|
||||
Reference in New Issue
Block a user