fbe 0.25.2 → 0.26.1

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: e3de49b140508afd1a989a717220dc48363172e87a1e505cd4389681a506978b
4
- data.tar.gz: 408c55e983349bcc82055d06922f20748d332b0beafac507340ee2745fac895a
3
+ metadata.gz: 4d139bdf4702ebd62afe4fe4e0edd82b25b1842955c4e233be08c323eb6f8375
4
+ data.tar.gz: 35dc6d0bc91574b1b7f967892232c4b55f9096156538de5eacb51411ee20dcc7
5
5
  SHA512:
6
- metadata.gz: e2f7b6c2b768012d2e600c03953053c756905a77e25b84b11be796efa678dc6a89ebd99d573761528c8295acf93a1e8f3c554ce755061ff771767625053ed195
7
- data.tar.gz: '0990166f5c5283d87687e2bb512ed2ae14e2afa35404ff81f9d02517c45ecac6ec187a8f3c2a05fb3bda9cb7a4220b6e0130aa94e35d069306e2224124980961'
6
+ metadata.gz: 3b65d4e592f10cfef206ff69a3f630cec44851382cfc87c5ca092bb31be7181a430241da91cb2e74628ad2cf3137f2b7034b746a319f940a4378ad3e997dd2f0
7
+ data.tar.gz: 9f894315a98b5972ba20be68cb6848d2c7743a4e64990b48e4cf33504cf9dd5716f054dc081cc99f5b5a8083d257057d527006d00f8464cd663f7f79b6e6bf52
data/Gemfile.lock CHANGED
@@ -47,7 +47,7 @@ GEM
47
47
  ast (2.4.3)
48
48
  backtrace (0.4.1)
49
49
  base64 (0.3.0)
50
- baza.rb (0.9.11)
50
+ baza.rb (0.9.12)
51
51
  backtrace (~> 0.4)
52
52
  elapsed (~> 0.0)
53
53
  faraday (~> 2.13)
@@ -70,13 +70,13 @@ GEM
70
70
  decoor (0.1.0)
71
71
  docile (1.4.1)
72
72
  drb (2.2.3)
73
- elapsed (0.1.0)
74
- loog (> 0)
75
- tago (> 0)
73
+ elapsed (0.2.0)
74
+ loog (~> 0.6)
75
+ tago (~> 0.1)
76
76
  ellipsized (0.3.0)
77
77
  ethon (0.16.0)
78
78
  ffi (>= 1.15.0)
79
- factbase (0.14.0)
79
+ factbase (0.14.3)
80
80
  backtrace (~> 0.4)
81
81
  decoor (~> 0.0)
82
82
  ellipsized (~> 0.3)
@@ -87,7 +87,7 @@ GEM
87
87
  others (~> 0.0)
88
88
  tago (~> 0.0)
89
89
  yaml (~> 0.3)
90
- faraday (2.13.3)
90
+ faraday (2.13.4)
91
91
  faraday-net_http (>= 2.0, < 3.5)
92
92
  json
93
93
  logger
@@ -120,8 +120,8 @@ GEM
120
120
  intercepted (0.2.0)
121
121
  iri (0.11.2)
122
122
  joined (0.4.0)
123
- json (2.13.0)
124
- judges (0.51.1)
123
+ json (2.13.2)
124
+ judges (0.52.1)
125
125
  backtrace (~> 0.4)
126
126
  baza.rb (~> 0.5)
127
127
  concurrent-ruby (~> 1.2)
@@ -173,7 +173,7 @@ GEM
173
173
  ostruct (0.6.3)
174
174
  others (0.1.1)
175
175
  parallel (1.27.0)
176
- parser (3.3.8.0)
176
+ parser (3.3.9.0)
177
177
  ast (~> 2.4.1)
178
178
  racc
179
179
  prism (1.4.0)
@@ -189,7 +189,7 @@ GEM
189
189
  regexp_parser (2.10.0)
190
190
  retries (0.0.5)
191
191
  rexml (3.4.1)
192
- rubocop (1.78.0)
192
+ rubocop (1.79.1)
193
193
  json (~> 2.3)
194
194
  language_server-protocol (~> 3.17.0.2)
195
195
  lint_roller (~> 1.1.0)
@@ -197,7 +197,7 @@ GEM
197
197
  parser (>= 3.3.0.2)
198
198
  rainbow (>= 2.2.2, < 4.0)
199
199
  regexp_parser (>= 2.9.3, < 3.0)
200
- rubocop-ast (>= 1.45.1, < 2.0)
200
+ rubocop-ast (>= 1.46.0, < 2.0)
201
201
  ruby-progressbar (~> 1.7)
202
202
  unicode-display_width (>= 2.4.0, < 4.0)
203
203
  rubocop-ast (1.46.0)
data/lib/fbe/octo.rb CHANGED
@@ -185,6 +185,7 @@ def Fbe.octo(options: $options, global: $global, loog: $loog)
185
185
  raise 'The name of the repo is nil' if name.nil?
186
186
  json = @origin.repository(name)
187
187
  id = json[:id]
188
+ raise "Repository #{name} not found" if id.nil?
188
189
  @loog.debug("GitHub repository #{name.inspect} has an ID: ##{id}")
189
190
  id
190
191
  end
@@ -49,11 +49,12 @@ end
49
49
  # @param [Judges::Options] options Options containing 'repositories' field with masks
50
50
  # @param [Hash] global Global cache for storing API responses
51
51
  # @param [Loog] loog Logger for debug output
52
+ # @param [quota_aware] Boolean Should we stop if quota is off?
52
53
  # @return [Array<String>] Shuffled list of repository full names (e.g., 'org/repo')
53
54
  # @raise [RuntimeError] If no repositories match the provided masks
54
55
  # @note Exclusion patterns must start with '-' (e.g., '-org/pattern*')
55
56
  # @note Results are shuffled to distribute load when processing
56
- def Fbe.unmask_repos(options: $options, global: $global, loog: $loog)
57
+ def Fbe.unmask_repos(options: $options, global: $global, loog: $loog, quota_aware: true)
57
58
  raise 'Repositories mask is not specified' unless options.repositories
58
59
  raise 'Repositories mask is empty' if options.repositories.empty?
59
60
  repos = []
@@ -77,5 +78,12 @@ def Fbe.unmask_repos(options: $options, global: $global, loog: $loog)
77
78
  raise "No repos found matching: #{options.repositories.inspect}" if repos.empty?
78
79
  repos.shuffle!
79
80
  loog.debug("Scanning #{repos.size} repositories: #{repos.joined}...")
80
- repos
81
+ return repos unless block_given?
82
+ repos.each do |repo|
83
+ if quota_aware && octo.off_quota?
84
+ $loog.info("No GitHub quota left, it is time to stop at #{repo}")
85
+ break
86
+ end
87
+ yield repo
88
+ end
81
89
  end
data/lib/fbe.rb CHANGED
@@ -10,5 +10,5 @@
10
10
  # License:: MIT
11
11
  module Fbe
12
12
  # Current version of the gem (changed by +.rultor.yml+ on every release)
13
- VERSION = '0.25.2' unless const_defined?(:VERSION)
13
+ VERSION = '0.26.1' unless const_defined?(:VERSION)
14
14
  end
@@ -64,6 +64,29 @@ class TestOcto < Fbe::Test
64
64
  assert_equal('dude56', nick)
65
65
  end
66
66
 
67
+ def test_reads_repo_id_by_name
68
+ WebMock.disable_net_connect!
69
+ stub_request(:get, 'https://api.github.com/rate_limit').to_return(
70
+ { body: '{}', headers: { 'X-RateLimit-Remaining' => '222' } }
71
+ )
72
+ o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new)
73
+ stub_request(:get, 'https://api.github.com/repos/foo/bar').to_return(
74
+ body: { id: 42 }.to_json, headers: { 'Content-Type': 'application/json' }
75
+ )
76
+ id = o.repo_id_by_name('foo/bar')
77
+ assert_equal(42, id)
78
+ end
79
+
80
+ def test_reads_lost_repo_id_by_name
81
+ WebMock.disable_net_connect!
82
+ stub_request(:get, 'https://api.github.com/rate_limit').to_return(
83
+ { body: '{}', headers: { 'X-RateLimit-Remaining' => '222' } }
84
+ )
85
+ o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new)
86
+ stub_request(:get, 'https://api.github.com/repos/foo/bar').to_return(status: 404)
87
+ assert_raises(StandardError) { o.repo_id_by_name('foo/bar') }
88
+ end
89
+
67
90
  def test_fails_user_request_when_off_quota
68
91
  WebMock.disable_net_connect!
69
92
  stub_request(:get, 'https://api.github.com/rate_limit').to_return(
@@ -25,6 +25,15 @@ class TestUnmaskRepos < Fbe::Test
25
25
  refute_includes(list, 'zerocracy/datum')
26
26
  end
27
27
 
28
+ def test_iterates_them
29
+ opts = Judges::Options.new({ 'testing' => true, 'repositories' => 'yegor256/tacit,zerocracy/*' })
30
+ list = []
31
+ Fbe.unmask_repos(options: opts, global: {}, loog: Loog::NULL) do |n|
32
+ list << n
33
+ end
34
+ assert_predicate(list.size, :positive?)
35
+ end
36
+
28
37
  def test_finds_case_insensitive
29
38
  opts = Judges::Options.new({ 'testing' => true, 'repositories' => 'Yegor256/*' })
30
39
  list = Fbe.unmask_repos(options: opts, global: {}, loog: Loog::NULL)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.2
4
+ version: 0.26.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko