gitlab-releases 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78806d4f54d19b124e736eaa493288e1942b45574eefb88c9777f5a8a9951e6e
4
- data.tar.gz: f09e1f9758ed572eae93a7be14ddf2b33718223f0d210c6229e663abba9949ba
3
+ metadata.gz: 1ee5944be724a7bf016c25ee0f56e31c4b270b8c812a9ce51abd87249aa4f587
4
+ data.tar.gz: 4c66c8ba98397bc550b4d0e80294805db8f15a8e97dfab6395de7c289a453ace
5
5
  SHA512:
6
- metadata.gz: bbc5d17a85e3af99014858f514deda6ad5afc4cfbafbd8dba6eeacf621f017ea71c6adf6f49179d9ea1ce0442a51751843727dfce8825b7f5cbe8a9641b82339
7
- data.tar.gz: 468f45b7a38e8d0a90f646cacd6d3ff6422562ad68f6568f2508bf36303a247663964fe5c638d6e49ff7e026ac66430801cd58fe2967ac0d0cbff5ae0aeed64e
6
+ metadata.gz: a01deb7460c318184f6f60c1ddfa63dd6cb69ea58055d3f30122701274ab3fa7d1fda235e84382be833a093e5fdecb951575cd29110f4113475179609be77fac
7
+ data.tar.gz: a91fad2b0ae7d3b341c3d536afa2ba05c095fbe9b4d6fc334f0a9aba839d03816e451016aebf7241841c04c8033fcd4f74d0307cf2e7676cc3cd4a68aa119eb7
data/CHANGELOG.md CHANGED
@@ -32,3 +32,11 @@
32
32
  ## [0.2.3] - 2023-10-11
33
33
 
34
34
  - Update ActiveSupport gem and loosen version restriction
35
+
36
+ ## [0.2.4] - 2023-11-03
37
+
38
+ - Remove logic for static release date. All release dates will be calculated based on the third Thursday of the month.
39
+
40
+ ## [0.2.5] - 2023-11-23
41
+
42
+ - Add methods to calculate the current version of a given date (`#current_minor_for_date`) and the previous minors for a specific version (`#previous_minors`)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-releases (0.2.3)
4
+ gitlab-releases (0.2.4)
5
5
  activesupport (~> 7.1)
6
6
  gitlab (~> 4.19.0)
7
7
  http (~> 5.1.0)
data/README.md CHANGED
@@ -12,7 +12,7 @@ Library to interact with GitLab releases and versions. The information is fetche
12
12
  Gemfile:
13
13
 
14
14
  ```
15
- gem 'gitlab-releases', '~> 0.2.2'
15
+ gem 'gitlab-releases', '~> 0.2.5'
16
16
  ```
17
17
 
18
18
  Install:
@@ -36,6 +36,9 @@ There are different methods available:
36
36
  * `current_version` - Returns the current GitLab minor version.
37
37
  * `next_versions` - Returns the next GitLab patch versions (for patch and security releases).
38
38
  * `previous_version` - Returns the return the latest patch of the previous minor version.
39
+ * `version_for_date` - Returns the active GitLab version for the given date
40
+ * `current_minor_for_date` - Returns the current GitLab minor for the given date
41
+ * `previous_minors` - Returns the previous minors for the given version
39
42
 
40
43
  To make use of it:
41
44
 
@@ -47,7 +50,7 @@ To make use of it:
47
50
  > require 'gitlab_releases'
48
51
  > GitlabReleases.upcoming_releases
49
52
  =>
50
- {"16.4"=>"2023-09-22",
53
+ {
51
54
  "16.5"=>"2023-10-22",
52
55
  "16.6"=>"2023-11-16",
53
56
  "16.7"=>"2023-12-21",
@@ -59,15 +62,22 @@ To make use of it:
59
62
  "17.1"=>"2024-06-20",
60
63
  "17.2"=>"2024-07-18",
61
64
  "17.3"=>"2024-08-15",
62
- "17.4"=>"2024-09-19"}
65
+ "17.4"=>"2024-09-19"
66
+ }
63
67
  > GitlabReleases.active_version
64
- => "16.5"
68
+ => "16.6"
65
69
  > GitlabReleases.current_version
66
- => "16.4"
70
+ => "16.5"
67
71
  > GitlabReleases.next_versions
68
- => ["16.4.2", "16.3.6", "16.2.9"]
72
+ => ["16.5.2", "16.4.3", "16.3.7"]
69
73
  > GitlabReleases.previous_version
70
- => "16.3.5"
74
+ => "16.4.2"
75
+ > GitlabReleases.version_for_date('2023-11-23')
76
+ => "16.7"
77
+ > GitlabReleases.current_minor_for_date('2023-11-23')
78
+ => "16.6"
79
+ > GitlabReleases.previous_minors
80
+ => ["16.6", "16.5", "16.4"]
71
81
  ```
72
82
 
73
83
  ## Contributing
@@ -3,12 +3,6 @@
3
3
  require 'active_support/all'
4
4
 
5
5
  class DateCalculator
6
- # Represents the minimum version that uses the new release date
7
- RELEASE_VERSION = '16.6'
8
-
9
- # Represents the minimum date that uses the new release date
10
- RELEASE_DATE = Date.parse('2023-11-16')
11
-
12
6
  # @param version [ReleaseVersion]
13
7
  # @param candidate_date [Date] - The month to calculate the release date. It should be
14
8
  # the first day of the month.
@@ -18,27 +12,13 @@ class DateCalculator
18
12
  end
19
13
 
20
14
  def execute
21
- result_date = if before_new_release_date?
22
- twenty_second_of_the_month
23
- else
24
- calculate_third_thursday_of_month
25
- end
26
-
27
- result_date.strftime('%Y-%m-%d')
15
+ calculate_third_thursday_of_month.strftime('%Y-%m-%d')
28
16
  end
29
17
 
30
18
  private
31
19
 
32
20
  attr_reader :next_version, :candidate_date
33
21
 
34
- def before_new_release_date?
35
- next_version.to_f < RELEASE_VERSION.to_f && candidate_date < RELEASE_DATE
36
- end
37
-
38
- def twenty_second_of_the_month
39
- Date.parse("#{candidate_date.year}-#{candidate_date.month}-22")
40
- end
41
-
42
22
  # If the first day of the month is a Thursday, it fetches the subsequent Two thursdays,
43
23
  # if not searches for the 3rd Thursday of the month.
44
24
  def calculate_third_thursday_of_month
@@ -75,8 +75,8 @@ class ReleaseVersions
75
75
 
76
76
  # Returns the scheduled major.minor for the given date
77
77
  def self.version_for_date(date)
78
- # Returns the release associated with the date by calling `releases_yaml` and fetching the
79
- # release whose date is greater than the given date.
78
+ # Returns the active release associated with the date by calling `releases_yaml` and fetching the
79
+ # release whose date is greater or equal than the given date.
80
80
  #
81
81
  # For example:
82
82
  #
@@ -99,6 +99,34 @@ class ReleaseVersions
99
99
  ReleaseVersion.new(row['version'])
100
100
  end
101
101
 
102
+ # Returns the current major.minor for the given date
103
+ def self.current_minor_for_date(date)
104
+ # Returns the current version associated with the date by calling `releases_yaml`
105
+ # and fetching the version whose release date is less or equal to the given date.
106
+ #
107
+ # For example:
108
+ #
109
+ # | Version | Date |
110
+ # |:--------|:---------------|
111
+ # | 16.3 | August 22nd |
112
+ # | 16.4 | September 22nd |
113
+ # | 16.5 | October 22nd |
114
+ # | 16.6 | November 16th |
115
+ # | 16.7 | December 21st |
116
+ #
117
+ # * For August 21st, the release should be 16.2
118
+ # * For August 22nd, the release should be 16.3
119
+ # * For August 23rd, the release should be 16.3
120
+ # * For November 17th, the release should be 16.6
121
+ return nil if releases_yaml.empty?
122
+
123
+ row = releases_yaml
124
+ .reverse
125
+ .detect { |release| date.to_date >= release['date'] }
126
+
127
+ ReleaseVersion.new(row['version'])
128
+ end
129
+
102
130
  # Returns the last patch of the previous minor version
103
131
  #
104
132
  # For example, if the current version is 16.4, then
@@ -114,6 +142,19 @@ class ReleaseVersions
114
142
  ::VersionSorter.sort(versions).uniq
115
143
  end
116
144
 
145
+ # Returns the previous major.minor versions of the major.minor version based on the
146
+ # releases.yml data
147
+ #
148
+ # For example:
149
+ # - If the current version is 16.7, the previous patch versions are 16.7, 16.6, and 16.5
150
+ # - If the current version is 17.1, the previous patch versions are 17.1, 16.11, and 16.10
151
+ def self.previous_minors(version)
152
+ versions = releases_yaml.map { |release| release['version'] }
153
+ .reverse
154
+
155
+ versions[versions.index(version), 3]
156
+ end
157
+
117
158
  def self.raw_versions
118
159
  ReleaseVersionClient.versions
119
160
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitlabReleases
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.5"
5
5
  end
@@ -33,6 +33,14 @@ module GitlabReleases
33
33
  ReleaseVersions.previous_version
34
34
  end
35
35
 
36
+ def self.current_minor_for_date(date)
37
+ ReleaseVersions.current_minor_for_date(date)
38
+ end
39
+
40
+ def self.previous_minors(version)
41
+ ReleaseVersions.previous_minors(version)
42
+ end
43
+
36
44
  def self.release_date
37
45
  ReleaseVersions.previous_release_date
38
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-releases
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mayra Cabrera
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-11 00:00:00.000000000 Z
11
+ date: 2023-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubygems_version: 3.3.13
130
+ rubygems_version: 3.4.17
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Utilities for GitLab releases and versions