fbe 0.41.0 → 0.41.2

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: 1e140ff5523bde9171719f3481941dfdf36b381696f313c98b7bb570b172ec49
4
- data.tar.gz: a0fa3c06b03e0d0de48ab5e00e9d7985e933b68d174f0625b6a5b9388d2d980a
3
+ metadata.gz: 4a52362d869769dc3027bd183f38ee8d3d8a58906c6f80ad117e3eb7c57aa5e0
4
+ data.tar.gz: b80bafc4f9058883d16ec102873fc209ac00f0884716f23375e0c0a635ce3364
5
5
  SHA512:
6
- metadata.gz: a1fdf1f6e32990d2f34dd33337b4b6f73f0e423092c09834bce6d216746d5c387eb61befa3786c907a84c37e75dd00a0058ff8816b4b7ddc9de09ed166564e55
7
- data.tar.gz: 5b7a3331b84db4c7b2b36b700e132987be7dd235b86b97ee7f3d4032a43b30d0bdf0d7a907700726bf7ca8fafcd13fb35e03c895f35b0e32964e57064c2d1a57
6
+ metadata.gz: 06d5913951e05e86c637b47ab753c242a6c797bbf80cffe7af16d41bdb705a542e39e510ddf420b153db90842116051f5ba5617766996517f467002172e401e9
7
+ data.tar.gz: 874aa12ad658ef1eae85cf083db1aec7b93654c4e995f2cc91e3dbf2bc782369a932c569cd50668b03a837a81bf0b078845d31945ff79df79bcb46b403dca202
@@ -15,7 +15,7 @@ jobs:
15
15
  - uses: actions/checkout@v5
16
16
  - uses: ruby/setup-ruby@v1
17
17
  with:
18
- ruby-version: 3.3
18
+ ruby-version: 3.4.7
19
19
  bundler-cache: true
20
20
  - run: bundle config set --global path "$(pwd)/vendor/bundle"
21
21
  - run: bundle install --no-color
@@ -16,6 +16,6 @@ jobs:
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
18
  - uses: actions/checkout@v5
19
- - uses: crate-ci/typos@v1.37.2
19
+ - uses: crate-ci/typos@v1.38.1
20
20
  with:
21
21
  config: .github/.typos.toml
data/Gemfile.lock CHANGED
@@ -60,11 +60,11 @@ GEM
60
60
  tago (~> 0.2)
61
61
  typhoeus (~> 1.4)
62
62
  benchmark (0.4.1)
63
- bigdecimal (3.2.3)
63
+ bigdecimal (3.3.1)
64
64
  builder (3.3.0)
65
65
  concurrent-ruby (1.3.5)
66
66
  connection_pool (2.5.4)
67
- crack (1.0.0)
67
+ crack (1.0.1)
68
68
  bigdecimal
69
69
  rexml
70
70
  decoor (0.1.0)
@@ -120,7 +120,7 @@ GEM
120
120
  intercepted (0.2.0)
121
121
  iri (0.11.2)
122
122
  joined (0.4.0)
123
- json (2.15.0)
123
+ json (2.15.1)
124
124
  judges (0.54.0)
125
125
  backtrace (~> 0.4)
126
126
  baza.rb (~> 0.10)
@@ -146,7 +146,7 @@ GEM
146
146
  logger (1.7.0)
147
147
  loog (0.6.1)
148
148
  logger (~> 1.0)
149
- minitest (5.25.5)
149
+ minitest (5.26.0)
150
150
  minitest-reporters (1.7.1)
151
151
  ansi
152
152
  builder
@@ -176,7 +176,7 @@ GEM
176
176
  parser (3.3.9.0)
177
177
  ast (~> 2.4.1)
178
178
  racc
179
- prism (1.5.1)
179
+ prism (1.5.2)
180
180
  public_suffix (6.0.2)
181
181
  qbash (0.4.5)
182
182
  backtrace (> 0)
@@ -185,11 +185,11 @@ GEM
185
185
  tago (> 0)
186
186
  racc (1.8.1)
187
187
  rainbow (3.1.1)
188
- rake (13.3.0)
188
+ rake (13.3.1)
189
189
  regexp_parser (2.11.3)
190
190
  retries (0.0.5)
191
191
  rexml (3.4.4)
192
- rubocop (1.81.1)
192
+ rubocop (1.81.6)
193
193
  json (~> 2.3)
194
194
  language_server-protocol (~> 3.17.0.2)
195
195
  lint_roller (~> 1.1.0)
@@ -207,10 +207,10 @@ GEM
207
207
  lint_roller (~> 1.1)
208
208
  rubocop (>= 1.75.0, < 2.0)
209
209
  rubocop-ast (>= 1.38.0, < 2.0)
210
- rubocop-performance (1.26.0)
210
+ rubocop-performance (1.26.1)
211
211
  lint_roller (~> 1.1)
212
212
  rubocop (>= 1.75.0, < 2.0)
213
- rubocop-ast (>= 1.44.0, < 2.0)
213
+ rubocop-ast (>= 1.47.1, < 2.0)
214
214
  rubocop-rake (0.7.1)
215
215
  lint_roller (~> 1.1)
216
216
  rubocop (>= 1.72.1)
@@ -248,7 +248,7 @@ GEM
248
248
  verbose (0.1.0)
249
249
  loog (~> 0.2)
250
250
  tago (~> 0.0)
251
- webmock (3.25.1)
251
+ webmock (3.26.0)
252
252
  addressable (>= 2.8.0)
253
253
  crack (>= 0.3.2)
254
254
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -95,16 +95,32 @@ class Fbe::Graph
95
95
  # @param [String] owner The repository owner (username or organization)
96
96
  # @param [String] name The repository name
97
97
  # @param [String] branch The branch name (e.g., "master" or "main")
98
- # @return [Integer] The total number of commits in the branch
98
+ # @param [Array<Array<String, String, String>> repos List of owner, name, branch
99
+ # @return [Integer, Array<Hash>] The total number of commits in the branch or array with hash
99
100
  # @example
100
101
  # graph = Fbe::Graph.new(token: 'github_token')
101
102
  # count = graph.total_commits('octocat', 'Hello-World', 'main')
102
103
  # puts count #=> 42
103
- def total_commits(owner, name, branch)
104
- result = query(
105
- <<~GRAPHQL
106
- {
107
- repository(owner: "#{owner}", name: "#{name}") {
104
+ # @example
105
+ # result = Fbe.github_graph.total_commits(
106
+ # repos: [
107
+ # ['zerocracy', 'fbe', 'master'],
108
+ # ['zerocracy', 'judges-action', 'master']
109
+ # ]
110
+ # )
111
+ # puts result #=>
112
+ # [{"owner"=>"zerocracy", "name"=>"fbe", "branch"=>"master", "total_commits"=>754},
113
+ # {"owner"=>"zerocracy", "name"=>"judges-action", "branch"=>"master", "total_commits"=>2251}]
114
+ def total_commits(owner = nil, name = nil, branch = nil, repos: nil)
115
+ raise 'Need owner, name and branch or repos' if owner.nil? && name.nil? && branch.nil? && repos.nil?
116
+ raise 'Owner, name and branch is required' if (owner.nil? || name.nil? || branch.nil?) && repos.nil?
117
+ raise 'Repos list cannot be empty' if owner.nil? && name.nil? && branch.nil? && repos&.empty?
118
+ raise 'Need only owner, name and branch or repos' if (!owner.nil? || !name.nil? || !branch.nil?) && !repos.nil?
119
+ repos ||= [[owner, name, branch]]
120
+ requests =
121
+ repos.each_with_index.map do |(owner, name, branch), i|
122
+ <<~GRAPHQL
123
+ repo_#{i}: repository(owner: "#{owner}", name: "#{name}") {
108
124
  ref(qualifiedName: "#{branch}") {
109
125
  target {
110
126
  ... on Commit {
@@ -115,10 +131,25 @@ class Fbe::Graph
115
131
  }
116
132
  }
117
133
  }
134
+ GRAPHQL
135
+ end
136
+ result = query("{\n#{requests.join("\n")}\n}")
137
+ if owner && name && branch
138
+ ref = result.repo_0&.ref
139
+ raise "Repository '#{owner}/#{name}' or branch '#{branch}' not found" unless ref&.target&.history
140
+ ref.target.history.total_count
141
+ else
142
+ repos.each_with_index.map do |(owner, name, branch), i|
143
+ ref = result.send(:"repo_#{i}")&.ref
144
+ raise "Repository '#{owner}/#{name}' or branch '#{branch}' not found" unless ref&.target&.history
145
+ {
146
+ 'owner' => owner,
147
+ 'name' => name,
148
+ 'branch' => branch,
149
+ 'total_commits' => ref.target.history.total_count
118
150
  }
119
- GRAPHQL
120
- )
121
- result.repository.ref.target.history.total_count
151
+ end
152
+ end
122
153
  end
123
154
 
124
155
  # Gets the total number of issues and pull requests in a repository.
@@ -451,12 +482,28 @@ class Fbe::Graph
451
482
 
452
483
  # Returns mock total commit count.
453
484
  #
454
- # @param [String] _owner Repository owner (ignored)
455
- # @param [String] _name Repository name (ignored)
456
- # @param [String] _branch Branch name (ignored)
457
- # @return [Integer] Always returns 1484
458
- def total_commits(_owner, _name, _branch)
459
- 1484
485
+ # @param [String] owner Repository owner
486
+ # @param [String] name Repository name
487
+ # @param [String] branch Branch name
488
+ # @param [Array<Array<String, String, String>> repos List of owner, name, branch
489
+ # @return [Integer, Array<Hash>] Returns 1484 for single repo or array of hashes
490
+ def total_commits(owner = nil, name = nil, branch = nil, repos: nil)
491
+ raise 'Need owner, name and branch or repos' if owner.nil? && name.nil? && branch.nil? && repos.nil?
492
+ raise 'Owner, name and branch is required' if (owner.nil? || name.nil? || branch.nil?) && repos.nil?
493
+ raise 'Repos list cannot be empty' if owner.nil? && name.nil? && branch.nil? && repos&.empty?
494
+ raise 'Need only owner, name and branch or repos' if (!owner.nil? || !name.nil? || !branch.nil?) && !repos.nil?
495
+ if owner && name && branch
496
+ 1484
497
+ else
498
+ repos.each_with_index.map do |(owner, name, branch), _i|
499
+ {
500
+ 'owner' => owner,
501
+ 'name' => name,
502
+ 'branch' => branch,
503
+ 'total_commits' => 1484
504
+ }
505
+ end
506
+ end
460
507
  end
461
508
 
462
509
  # Returns mock issue type event data.
data/lib/fbe/iterate.rb CHANGED
@@ -330,7 +330,9 @@ class Fbe::Iterate
330
330
  rescue Fbe::OffQuota => e
331
331
  @loog.info(e.message)
332
332
  ensure
333
- if defined?(repos) && defined?(before) && defined?(starts)
333
+ if defined?(repos) && !repos.nil? &&
334
+ defined?(before) && !before.nil? &&
335
+ defined?(starts) && !starts.nil?
334
336
  repos.each do |repo|
335
337
  next if before[repo] == starts[repo]
336
338
  f =
data/lib/fbe/octo.rb CHANGED
@@ -1318,43 +1318,60 @@ class Fbe::FakeOctokit
1318
1318
  ]
1319
1319
  end
1320
1320
 
1321
- def issue_events(_repo, _number)
1322
- [
1323
- {
1324
- id: 126, actor: { login: 'user', id: 411, type: 'User' },
1325
- event: 'labeled', created_at: Time.parse('2025-05-30 14:41:00 UTC'),
1326
- label: { name: 'bug', color: 'd73a4a' }
1327
- },
1328
- {
1329
- id: 206, actor: { login: 'user', id: 411, type: 'User' },
1330
- event: 'mentioned', created_at: Time.parse('2025-05-30 14:41:10 UTC')
1331
- },
1332
- {
1333
- id: 339, actor: { login: 'user2', id: 422, type: 'User' },
1334
- event: 'subscribed', created_at: Time.parse('2025-05-30 14:41:10 UTC')
1335
- },
1336
- {
1337
- id: 490, actor: { login: 'github-actions[bot]', id: 41_898_282, type: 'Bot' },
1338
- event: 'renamed', created_at: Time.parse('2025-05-30 14:41:30 UTC'),
1339
- rename: { from: 'some title', to: 'some title 2' }
1340
- },
1341
- {
1342
- id: 505, actor: { login: 'user', id: 411, type: 'User' },
1343
- event: 'subscribed', created_at: Time.parse('2025-05-30 16:18:24 UTC')
1344
- },
1345
- {
1346
- id: 608, actor: { login: 'user2', id: 422, type: 'User', test: 123 },
1347
- event: 'assigned', created_at: Time.parse('2025-05-30 17:59:08 UTC'),
1348
- assignee: { login: 'user2', id: 422, type: 'User' },
1349
- assigner: { login: 'user', id: 411, type: 'User' }
1350
- },
1351
- {
1352
- id: 776, actor: { login: 'user2', id: 422, type: 'User' },
1353
- event: 'referenced', commit_id: '4621af032170f43d',
1354
- commit_url: 'https://api.github.com/repos/foo/foo/commits/4621af032170f43d',
1355
- created_at: Time.parse('2025-05-30 19:57:50 UTC')
1356
- }
1357
- ]
1321
+ def issue_events(_repo, number)
1322
+ if number == 120
1323
+ [
1324
+ {
1325
+ id: 1010, actor: { login: 'user2', id: 422, type: 'User' },
1326
+ event: 'assigned', created_at: Time.parse('2025-10-27 14:00:00 UTC'),
1327
+ assignee: { login: 'user2', id: 422, type: 'User' },
1328
+ assigner: { login: 'user', id: 411, type: 'User' }
1329
+ },
1330
+ {
1331
+ id: 1011, actor: { login: 'user2', id: 422, type: 'User' },
1332
+ event: 'unassigned', created_at: Time.parse('2025-10-27 15:00:00 UTC'),
1333
+ assignee: { login: 'user2', id: 422, type: 'User' },
1334
+ assigner: { login: 'user', id: 411, type: 'User' }
1335
+ }
1336
+ ]
1337
+ else
1338
+ [
1339
+ {
1340
+ id: 126, actor: { login: 'user', id: 411, type: 'User' },
1341
+ event: 'labeled', created_at: Time.parse('2025-05-30 14:41:00 UTC'),
1342
+ label: { name: 'bug', color: 'd73a4a' }
1343
+ },
1344
+ {
1345
+ id: 206, actor: { login: 'user', id: 411, type: 'User' },
1346
+ event: 'mentioned', created_at: Time.parse('2025-05-30 14:41:10 UTC')
1347
+ },
1348
+ {
1349
+ id: 339, actor: { login: 'user2', id: 422, type: 'User' },
1350
+ event: 'subscribed', created_at: Time.parse('2025-05-30 14:41:10 UTC')
1351
+ },
1352
+ {
1353
+ id: 490, actor: { login: 'github-actions[bot]', id: 41_898_282, type: 'Bot' },
1354
+ event: 'renamed', created_at: Time.parse('2025-05-30 14:41:30 UTC'),
1355
+ rename: { from: 'some title', to: 'some title 2' }
1356
+ },
1357
+ {
1358
+ id: 505, actor: { login: 'user', id: 411, type: 'User' },
1359
+ event: 'subscribed', created_at: Time.parse('2025-05-30 16:18:24 UTC')
1360
+ },
1361
+ {
1362
+ id: 608, actor: { login: 'user2', id: 422, type: 'User', test: 123 },
1363
+ event: 'assigned', created_at: Time.parse('2025-05-30 17:59:08 UTC'),
1364
+ assignee: { login: 'user2', id: 422, type: 'User' },
1365
+ assigner: { login: 'user', id: 411, type: 'User' }
1366
+ },
1367
+ {
1368
+ id: 776, actor: { login: 'user2', id: 422, type: 'User' },
1369
+ event: 'referenced', commit_id: '4621af032170f43d',
1370
+ commit_url: 'https://api.github.com/repos/foo/foo/commits/4621af032170f43d',
1371
+ created_at: Time.parse('2025-05-30 19:57:50 UTC')
1372
+ }
1373
+ ]
1374
+ end
1358
1375
  end
1359
1376
 
1360
1377
  def pull_request_comments(_name, _number)
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.41.0' unless const_defined?(:VERSION)
13
+ VERSION = '0.41.2' unless const_defined?(:VERSION)
14
14
  end
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.41.0
4
+ version: 0.41.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko