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 +4 -4
- data/.github/workflows/typos.yml +1 -1
- data/Gemfile.lock +1 -1
- data/lib/fbe/github_graph.rb +62 -15
- data/lib/fbe/iterate.rb +3 -1
- data/lib/fbe.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5e897714a3789136f4e029b50a785506d23a21e3a666c670ce470aadc87eb1c
|
4
|
+
data.tar.gz: f1a86de706ff760e725f56ac060c4a36c5b5a5c4def42ffb4c46c289852b2e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51a2136d5e94ee50f1fa941e368976a91502e8a4469d0e4bd4fcf87cb6b0f90b86393224a28daf48b315c072c2f4c474eafa89fc41ce526df15b193be6d85bbb
|
7
|
+
data.tar.gz: dc51650d3aa4c74680070d50fac3488b6d49ea591ad8231a6a2b3e311f1abb63f11aeea895545b6fed63a1c7c385da068dd53f53ed931c192b710e93302d3cf3
|
data/.github/workflows/typos.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/fbe/github_graph.rb
CHANGED
@@ -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
|
-
# @
|
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
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
-
|
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]
|
455
|
-
# @param [String]
|
456
|
-
# @param [String]
|
457
|
-
# @
|
458
|
-
|
459
|
-
|
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) &&
|
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