From 6dd60d7c70a63ac884515387cd8c92bb97433e1b Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 9 Jul 2018 18:01:19 -0300 Subject: [PATCH 1/1] 13668: Adds package version to workbench. Reports versions on dialog. API & Workbench package versions are displayed on the 'Show version' & 'Report problem' dialogs. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- apps/workbench/app/helpers/version_helper.rb | 6 ++++++ .../views/application/_report_issue_popup.html.erb | 6 ++++-- apps/workbench/config/application.default.yml | 5 +++++ apps/workbench/lib/app_version.rb | 14 ++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/apps/workbench/app/helpers/version_helper.rb b/apps/workbench/app/helpers/version_helper.rb index 915c3a9d38..c372adbe12 100644 --- a/apps/workbench/app/helpers/version_helper.rb +++ b/apps/workbench/app/helpers/version_helper.rb @@ -9,6 +9,12 @@ module VersionHelper arvados_api_client.discovery[:source_version] end + # Get the package_version given in the API server's discovery + # document. + def api_package_version + arvados_api_client.discovery[:package_version] + end + # URL for browsing source code for the given version. def version_link_target version "https://arvados.org/projects/arvados/repository/changes?rev=#{version.sub(/-.*/, "")}" diff --git a/apps/workbench/app/views/application/_report_issue_popup.html.erb b/apps/workbench/app/views/application/_report_issue_popup.html.erb index 86d550a33f..8823fdd5f7 100644 --- a/apps/workbench/app/views/application/_report_issue_popup.html.erb +++ b/apps/workbench/app/views/application/_report_issue_popup.html.erb @@ -14,8 +14,10 @@ SPDX-License-Identifier: AGPL-3.0 %> additional_info_str = additional_info.map {|k,v| "#{k}=#{v}"}.join("\n") additional_info['api_source_version'] = api_source_version + additional_info['api_package_version'] = api_package_version additional_info['generated_at'] = generated_at additional_info['workbench_version'] = AppVersion.hash + additional_info['workbench_package_version'] = AppVersion.package_version additional_info['arvados_base'] = arvados_base additional_info['support_email'] = support_email additional_info['error_message'] = params[:error_message] if params[:error_message] @@ -73,7 +75,7 @@ SPDX-License-Identifier: AGPL-3.0 %>

- <%= link_to AppVersion.hash, version_link_target(AppVersion.hash) %> + <%= AppVersion.package_version %> (<%= link_to AppVersion.hash, version_link_target(AppVersion.hash) %>)

@@ -82,7 +84,7 @@ SPDX-License-Identifier: AGPL-3.0 %>

- <%= link_to api_source_version, version_link_target(api_source_version) %> + <%= api_package_version %> (<%= link_to api_source_version, version_link_target(api_source_version) %>)

diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml index d5f46feab6..e4ec413128 100644 --- a/apps/workbench/config/application.default.yml +++ b/apps/workbench/config/application.default.yml @@ -201,6 +201,11 @@ common: # "git log". source_version: false + # Override the automatic package string. With the default value of + # false, the package string is read from package-build.version in + # Rails.root (included in vendor packages). + package_version: false + # report notification to and from addresses issue_reporter_email_from: arvados@example.com issue_reporter_email_to: arvados@example.com diff --git a/apps/workbench/lib/app_version.rb b/apps/workbench/lib/app_version.rb index cc4b4dee19..303d853ec5 100644 --- a/apps/workbench/lib/app_version.rb +++ b/apps/workbench/lib/app_version.rb @@ -15,6 +15,7 @@ class AppVersion def self.forget @hash = nil + @package_version = nil end # Return abbrev commit hash for current code version: "abc1234", or @@ -54,4 +55,17 @@ class AppVersion @hash || "unknown" end + + def self.package_version + if (cached = Rails.configuration.package_version || @package_version) + return cached + end + + begin + @package_version = IO.read(Rails.root.join("package-build.version")).strip + rescue Errno::ENOENT + end + + @package_version || "unknown" + end end -- 2.30.2