fbe 0.44.1 → 0.46.0

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: 402427f9ad7494a0b2986eb8c34263e0c2ad09dd374831eaa30c13c6609e2522
4
- data.tar.gz: 6815e1fe899316cbaf7bc5eee454076d3cf9ccbee4bfb0006357d8d08e413ff6
3
+ metadata.gz: 519554aa1f1b5867cb510a32c18b02abbfd23e53d2a9c4ef1a8d69c062b29251
4
+ data.tar.gz: 54ab82081ac47eeba118a5a781766d235567fa4223953a449ae4178a33625a6e
5
5
  SHA512:
6
- metadata.gz: 5ba173a218ba4fb35a1c6107533db8be655f86492efbd6c47b13315e8f5ac5206e24190593c1d5637fe029408c36da048977c307dabadcbf917deac4c4cab026
7
- data.tar.gz: 5f143ed59036fe621e267723362dff1ae3fc97c6e46901f97b4cf4dd345c6da4fc8764ddc0c23505c3fe2c532d034de08e93747f53a0d49204e410ef71ce3004
6
+ metadata.gz: 49b3280b79b52dda1cde1d082475fc1a5bfc2cdbf4158cb86622582333e0a01d9d837d9649f5bfe9b456fc22c8c97ac904930e78535a500941bc413695a14044
7
+ data.tar.gz: 027f14cfde422c350996b4a7ab036c10a24fb85abd37230519d1b26871d38526a3ad8772a09df99b7bbca4db88625b523c414c491ebe5cb05a71037646143b56
@@ -389,6 +389,48 @@ class Fbe::Graph
389
389
  end
390
390
  end
391
391
 
392
+ # Get total commits pushed to default branch
393
+ #
394
+ # @param [String] owner The repository owner (username or organization)
395
+ # @param [String] name The repository name
396
+ # @param [Time] since The datetime from
397
+ # @return [Hash] A hash with total commits and hocs
398
+ def total_commits_pushed(owner, name, since)
399
+ # @todo #1223:60min Missing pagination could cause performance issues or API failures. You need add
400
+ # pagination for commit history, for more info see
401
+ # https://github.com/zerocracy/fbe/pull/366#discussion_r2610751758
402
+ result = query(
403
+ <<~GRAPHQL
404
+ {
405
+ repository(owner: "#{owner}", name: "#{name}") {
406
+ defaultBranchRef {
407
+ target {
408
+ ... on Commit {
409
+ history(since: "#{since.utc.iso8601}") {
410
+ totalCount
411
+ nodes {
412
+ oid
413
+ parents {
414
+ totalCount
415
+ }
416
+ additions
417
+ deletions
418
+ }
419
+ }
420
+ }
421
+ }
422
+ }
423
+ }
424
+ }
425
+ GRAPHQL
426
+ ).to_h
427
+ commits = result.dig('repository', 'defaultBranchRef', 'target', 'history', 'nodes')
428
+ {
429
+ 'commits' => result.dig('repository', 'defaultBranchRef', 'target', 'history', 'totalCount') || 0,
430
+ 'hoc' => commits.nil? ? 0 : commits.sum { (_1['additions'] || 0) + (_1['deletions'] || 0) }
431
+ }
432
+ end
433
+
392
434
  private
393
435
 
394
436
  # Creates or returns a cached GraphQL client instance.
@@ -617,6 +659,13 @@ class Fbe::Graph
617
659
  ]
618
660
  end
619
661
 
662
+ def total_commits_pushed(_owner, _name, _since)
663
+ {
664
+ 'commits' => 29,
665
+ 'hoc' => 1857
666
+ }
667
+ end
668
+
620
669
  private
621
670
 
622
671
  # Generates mock conversation thread data.
data/lib/fbe/octo.rb CHANGED
@@ -771,6 +771,39 @@ class Fbe::FakeOctokit
771
771
  additions: 12,
772
772
  deletions: 5
773
773
  }
774
+ elsif number == 172
775
+ {
776
+ id: 1_990_323_142,
777
+ number: 172,
778
+ url: 'https://api.github.com/repos/yegor256/judges/pulls/93',
779
+ node_id: 'PR_kwDOL6GCO852oevG',
780
+ state: 'closed',
781
+ locked: false,
782
+ title: '#999 new feature',
783
+ user: {
784
+ login: 'test',
785
+ id: 88_084_038,
786
+ node_id: 'MDQ6VXNlcjE2NDYwMjA=',
787
+ type: 'User',
788
+ site_admin: false
789
+ },
790
+ base: {
791
+ ref: 'master',
792
+ sha: '125f234967de0f690805c6943e78db42a294c1a',
793
+ repo: { id: repo, name: 'judges' }
794
+ },
795
+ head: {
796
+ ref: 'zerocracy/judges',
797
+ sha: '74d0c234967de0f690805c6943e78db42a294c1a'
798
+ },
799
+ merged_at: Time.now,
800
+ comments: 2,
801
+ review_comments: 2,
802
+ commits: 1,
803
+ additions: 3,
804
+ deletions: 3,
805
+ changed_files: 2
806
+ }
774
807
  else
775
808
  {
776
809
  id: 42,
@@ -1159,8 +1192,6 @@ class Fbe::FakeOctokit
1159
1192
  payload: {
1160
1193
  push_id: 42,
1161
1194
  ref: 'refs/heads/master',
1162
- size: 1,
1163
- distinct_size: 0,
1164
1195
  head: 'b7089c51cc2526a0d2619d35379f921d53c72731',
1165
1196
  before: '12d3bff1a55bad50ee2e8f29ade7f1c1e07bb025'
1166
1197
  },
@@ -1225,49 +1256,22 @@ class Fbe::FakeOctokit
1225
1256
  payload: {
1226
1257
  action: 'closed',
1227
1258
  number: 172,
1228
- ref_type: 'tag',
1229
- ref: 'foo',
1230
1259
  pull_request: {
1231
1260
  url: 'https://api.github.com/repos/yegor256/judges/pulls/93',
1232
1261
  id: 1_990_323_142,
1233
- node_id: 'PR_kwDOL6GCO852oevG',
1234
1262
  number: 172,
1235
- state: 'closed',
1236
- locked: false,
1237
- title: '#999 new feature',
1238
- user: {
1239
- login: 'test',
1240
- id: 88_084_038,
1241
- node_id: 'MDQ6VXNlcjE2NDYwMjA=',
1242
- type: 'User',
1243
- site_admin: false
1244
- },
1245
1263
  base: {
1246
- label: 'zerocracy:master',
1247
1264
  ref: 'master',
1248
- user: {
1249
- login: 'zerocracy',
1250
- id: 24_234_201
1251
- },
1265
+ sha: '93fe488b9967de0f690805c6943e78db42a294c1a',
1252
1266
  repo: {
1253
1267
  id: repo,
1254
- node_id: 'R_kgDOK2_4Aw',
1255
- name: 'baza',
1256
- full_name: 'zerocracy/baza',
1257
- private: false
1268
+ name: 'baza'
1258
1269
  }
1259
1270
  },
1260
1271
  head: {
1261
1272
  ref: 'zerocracy/baza',
1262
1273
  sha: '74d0c234967de0f690805c6943e78db42a294c1a'
1263
- },
1264
- merged_at: Time.now,
1265
- comments: 2,
1266
- review_comments: 2,
1267
- commits: 1,
1268
- additions: 3,
1269
- deletions: 3,
1270
- changed_files: 2
1274
+ }
1271
1275
  }
1272
1276
  }
1273
1277
  },
@@ -1280,49 +1284,22 @@ class Fbe::FakeOctokit
1280
1284
  payload: {
1281
1285
  action: 'closed',
1282
1286
  number: 172,
1283
- ref_type: 'tag',
1284
- ref: 'foo',
1285
1287
  pull_request: {
1286
1288
  url: 'https://api.github.com/repos/yegor256/judges/pulls/93',
1287
1289
  id: 1_990_323_142,
1288
- node_id: 'PR_kwDOL6GCO852oevG',
1289
1290
  number: 172,
1290
- state: 'closed',
1291
- locked: false,
1292
- title: '#999 new feature',
1293
- user: {
1294
- login: 'test',
1295
- id: 88_084_038,
1296
- node_id: 'MDQ6VXNlcjE2NDYwMjA=',
1297
- type: 'User',
1298
- site_admin: false
1299
- },
1300
1291
  base: {
1301
- label: 'zerocracy:master',
1302
1292
  ref: 'master',
1303
- user: {
1304
- login: 'zerocracy',
1305
- id: 24_234_201
1306
- },
1293
+ sha: '125f234967de0f690805c6943e78db42a294c1a',
1307
1294
  repo: {
1308
1295
  id: repo,
1309
- node_id: 'R_kgDOK2_4Aw',
1310
- name: 'judges-action',
1311
- full_name: 'zerocracy/judges-action',
1312
- private: false
1296
+ name: 'judges-action'
1313
1297
  }
1314
1298
  },
1315
1299
  head: {
1316
1300
  ref: 'zerocracy/judges-action',
1317
1301
  sha: '74d0c234967de0f690805c6943e78db42a294c1a'
1318
- },
1319
- merged_at: Time.now,
1320
- comments: 2,
1321
- review_comments: 2,
1322
- commits: 1,
1323
- additions: 3,
1324
- deletions: 3,
1325
- changed_files: 2
1302
+ }
1326
1303
  }
1327
1304
  }
1328
1305
  }
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.44.1' unless const_defined?(:VERSION)
13
+ VERSION = '0.46.0' 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.44.1
4
+ version: 0.46.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko