fbe 0.41.0 → 0.41.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: 1e140ff5523bde9171719f3481941dfdf36b381696f313c98b7bb570b172ec49
4
- data.tar.gz: a0fa3c06b03e0d0de48ab5e00e9d7985e933b68d174f0625b6a5b9388d2d980a
3
+ metadata.gz: e5e897714a3789136f4e029b50a785506d23a21e3a666c670ce470aadc87eb1c
4
+ data.tar.gz: f1a86de706ff760e725f56ac060c4a36c5b5a5c4def42ffb4c46c289852b2e91
5
5
  SHA512:
6
- metadata.gz: a1fdf1f6e32990d2f34dd33337b4b6f73f0e423092c09834bce6d216746d5c387eb61befa3786c907a84c37e75dd00a0058ff8816b4b7ddc9de09ed166564e55
7
- data.tar.gz: 5b7a3331b84db4c7b2b36b700e132987be7dd235b86b97ee7f3d4032a43b30d0bdf0d7a907700726bf7ca8fafcd13fb35e03c895f35b0e32964e57064c2d1a57
6
+ metadata.gz: 51a2136d5e94ee50f1fa941e368976a91502e8a4469d0e4bd4fcf87cb6b0f90b86393224a28daf48b315c072c2f4c474eafa89fc41ce526df15b193be6d85bbb
7
+ data.tar.gz: dc51650d3aa4c74680070d50fac3488b6d49ea591ad8231a6a2b3e311f1abb63f11aeea895545b6fed63a1c7c385da068dd53f53ed931c192b710e93302d3cf3
@@ -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
@@ -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
@@ -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.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.1' 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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko