From 74eff5456c8655e6783ffe49a96042320af3848c Mon Sep 17 00:00:00 2001 From: DJ Sundog Date: Tue, 11 Jul 2017 17:32:16 -0700 Subject: [PATCH] =?UTF-8?q?First=20lame=20pass=20at=20adding=20optional=20?= =?UTF-8?q?git=20commit=20hash=20display=20on=20/about/=E2=80=A6=20(#67)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * First lame pass at adding optional git commit hash display on /about/more page. Currently, this is implemented by checking for the existence of a file called CURRENT_RELEASE in the home directory of the user running Mastodon. If the file exists, its contents are added. I've modified my update process to include the following before precompiling assets: git log -1 | head -n 1 | cut -d " " -f2 > ~/CURRENT_RELEASE That puts the current commit hash into the file ~/CURRENT_RELEASE, but you figured that out because you're a smart cookie. As I am quite sure this is a horrible methodology for implementing this, I look forward to any improvements you have to offer! * Updated to handle instances that share a user - the CURRENT_RELEASE file now lives in the instance's base directory. This also requires modifying the update hook to `git log -1 | head -n 1 | cut -d " " -f2 > CURRENT_RELEASE` --- app/presenters/instance_presenter.rb | 9 +++++++++ app/views/about/_version.html.haml | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb index 9a69809d0..c96eaa1cb 100644 --- a/app/presenters/instance_presenter.rb +++ b/app/presenters/instance_presenter.rb @@ -29,4 +29,13 @@ class InstancePresenter def version_number Mastodon::Version end + + def commit_hash + current_release_file = Pathname.new('CURRENT_RELEASE').expand_path + if current_release_file.file? + IO.read(current_release_file) + else + "" + end + end end diff --git a/app/views/about/_version.html.haml b/app/views/about/_version.html.haml index f8ebc4c6d..3ed35da51 100644 --- a/app/views/about/_version.html.haml +++ b/app/views/about/_version.html.haml @@ -1,4 +1,9 @@ .panel .panel-header= t 'about.version' .panel-body - %strong= version.version_number + - if @instance_presenter.commit_hash == "" + %strong= version.version_number + - else + %strong= version.version_number + %strong= "#{@instance_presenter.commit_hash}" +