X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f4ca9ad94a6bb006d1f3c7ba207837f1736d1247..cbf93e8d897448dbd52369afe89fef2392140ff1:/services/api/lib/app_version.rb diff --git a/services/api/lib/app_version.rb b/services/api/lib/app_version.rb index 769f4e5ed8..335608b2b6 100644 --- a/services/api/lib/app_version.rb +++ b/services/api/lib/app_version.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + # If you change this file, you'll probably also want to make the same # changes in apps/workbench/lib/app_version.rb. @@ -11,6 +15,7 @@ class AppVersion def self.forget @hash = nil + @package_version = nil end # Return abbrev commit hash for current code version: "abc1234", or @@ -49,4 +54,18 @@ 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 + @package_version = "unknown" + end + + @package_version + end end