Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axilleas@axilleas.me>2021-05-24 22:41:42 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2021-05-25 11:52:28 +0300
commitdea01219058db8c8d3b5023ac2f6c4e6664c16bb (patch)
tree72d2f448152f1a67a46235b16dbbff2a1a9267f0 /lib
parentb0e72ae5fa1ad0517bbc94ef79a51b00282f3221 (diff)
Take into account the next major version for the dropdown
This fixes the case where a new major version is the next version to be released, and the dropdown incorrectly shows a next patch version that doesn't exist.
Diffstat (limited to 'lib')
-rw-r--r--lib/helpers/versions.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/helpers/versions.rb b/lib/helpers/versions.rb
index 014a1c0a..e467c43f 100644
--- a/lib/helpers/versions.rb
+++ b/lib/helpers/versions.rb
@@ -63,9 +63,20 @@ module Nanoc::Helpers
def next_version
latest_stable = data_versions[:online].first
- next_major, next_minor = latest_stable.split('.')
+ latest_major, latest_minor = latest_stable.split('.')
+ _, last_minor = data_versions[:last_before_new_major].first.split('.')
- "#{next_major}.#{next_minor.to_i + 1}"
+ #
+ # If the minor version of the latest online version
+ # is equal to last_minor, bump the major version
+ # and set patch to 0. This is for the case where a new
+ # major version is the next version to be released.
+ #
+ if latest_minor == last_minor
+ "#{latest_major.to_i + 1}.0"
+ else
+ "#{latest_major}.#{latest_minor.to_i + 1}"
+ end
end
def dotcom