diff options
author | Sarah German <sgerman@gitlab.com> | 2023-01-20 23:07:34 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2023-01-20 23:07:34 +0300 |
commit | 3a62c8c59da6a892a661325d48424595f15d602c (patch) | |
tree | 6e431d7830d7d2ef0fef47f71a3fa4d65fa050d3 /lib | |
parent | f44e552801fe0af6ccba9c11a9ee5280ffb98e53 (diff) |
Fix check for current stable version
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helpers/versions.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/helpers/versions.rb b/lib/helpers/versions.rb index 05e093aa..c34e38ac 100644 --- a/lib/helpers/versions.rb +++ b/lib/helpers/versions.rb @@ -15,15 +15,6 @@ module Nanoc::Helpers end # - # Get online versions from the JSON file. - # - def get_versions - file = File.read('./content/versions.json') - parsed = JSON.parse(file) - parsed[0] - end - - # # Returns the site version using the branch or tag from the CI build. # def site_version @@ -32,7 +23,7 @@ module Nanoc::Helpers version_tag else # If this wasn't built on CI, this is a local site that can default to the pre-release version. - get_versions["next"] + config[:online_versions][:next] end end @@ -43,7 +34,7 @@ module Nanoc::Helpers # in the case of the pre-release site. # def docsearch_version - if get_versions["next"] == site_version + if config[:online_versions][:next] == site_version ENV.fetch('CI_DEFAULT_BRANCH', nil) else site_version @@ -51,6 +42,13 @@ module Nanoc::Helpers end # + # Returns the current stable version. + # + def get_current_stable_version + config[:online_versions][:current] + end + + # # Check if this site version is the latest. # # We consider two versions to be "latest": @@ -58,7 +56,7 @@ module Nanoc::Helpers # 2) The most recent stable release, which is "current" in versions.json. # def latest? - ENV['CI_COMMIT_REF_NAME'] == ENV['CI_DEFAULT_BRANCH'] || ENV['CI_COMMIT_REF_NAME'] == get_versions["current"] + ENV['CI_COMMIT_REF_NAME'] == ENV['CI_DEFAULT_BRANCH'] || ENV['CI_COMMIT_REF_NAME'] == get_current_stable_version end # |