cobench 0.0.31 → 0.0.34

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: b950466b65dafeb1dc0ec2066fcd3a61e75d0470b2810944181a0a7704d8b2d6
4
- data.tar.gz: cb692c9353443c05b1b4912a76305617212d532da458ff86ea1df12e2d11f406
3
+ metadata.gz: bde636a5d9fea9b6b334d82f9333608b806bfe9479b16bddf742e8718e6c5e4a
4
+ data.tar.gz: 2cd0411ce9b5d13016e81998fb971da4c7eb6975c69f74758b0400c727f1be5b
5
5
  SHA512:
6
- metadata.gz: 5bbbbe914c7a2a627d518d1eb5b5baf1466bd60d15252098fcf9d0e2b7a3b41c3ceaeed22df4603b7e8ae404dff45e155b876290866e6ade19dffa47673e70f0
7
- data.tar.gz: 460efed0d36d92adbe5549cb3299cf0071aa299dadf98e45a964b6e79f75d838b4f44d74a7d24a4532b9cb3f3c96d0b5e4c4ec9d3ecb129d42a9e79039c463eb
6
+ metadata.gz: 29ab01d89a72192c4b0e20e8e0ae6239fc65268ad18c65c593a74f8646eef0d9e1802d74b87b77389322a029087d794fff9917a4a35a166d0c2bfe7e13938d0e
7
+ data.tar.gz: ad5f1d829346f084a69efb40b77841173128121f4f62cf5f98f2951235fb9bbe5f95db1574ec82b1599a18b7c74cde659e45958b2f92132963082cd53f5d9821
data/assets/index.xsl CHANGED
@@ -58,7 +58,8 @@ SOFTWARE.
58
58
  });
59
59
  </script>
60
60
  <style>
61
- td, th { font-family: monospace; font-size: 18px; }
61
+ td, th { font-family: monospace; font-size: 18px; line-height: 1em; }
62
+ td.top { vertical-align: middle; }
62
63
  .num { text-align: right; }
63
64
  .left { border-bottom: 0; }
64
65
  section { width: auto; }
@@ -143,6 +144,7 @@ SOFTWARE.
143
144
  <xsl:text>issues</xsl:text>
144
145
  </a>
145
146
  <xsl:text>. </xsl:text>
147
+ <xsl:text>"Msgs" is the total number of messages posted as a reviewer in pull requests. </xsl:text>
146
148
  <xsl:text>"Pulls" is the total number of </xsl:text>
147
149
  <a href="https://docs.github.com/en/pull-requests">
148
150
  <xsl:text>pull requests</xsl:text>
@@ -265,9 +267,12 @@ SOFTWARE.
265
267
  </xsl:template>
266
268
  <xsl:template match="coder">
267
269
  <tr>
268
- <td class="num">
270
+ <td class="num top">
269
271
  <xsl:variable name="score" select="metrics/m[@id='Score']"/>
270
- <xsl:variable name="pos" select="count(/cobench/coders/coder[metrics/m[@id='Score'] &lt; $score]) + 1"/>
272
+ <xsl:variable name="pos" select="count(/cobench/coders/coder[metrics/m[@id='Score'] &gt; $score]) + 1"/>
273
+ <xsl:attribute name="title">
274
+ <xsl:value-of select="$pos"/>
275
+ </xsl:attribute>
271
276
  <xsl:if test="$pos &lt;= 8">
272
277
  <xsl:text>#</xsl:text>
273
278
  <xsl:value-of select="$pos"/>
data/bin/cobench CHANGED
@@ -80,6 +80,7 @@ def div(a, b)
80
80
  end
81
81
 
82
82
  def actual(ms)
83
+ return 0 if ms.nil?
83
84
  return ms[:actual] if ms.key?(:actual)
84
85
  ms[:total]
85
86
  end
@@ -157,7 +158,8 @@ def build_xml(opts, loog)
157
158
  'Pulls' => 250,
158
159
  'Issues' => 50,
159
160
  'Commits' => 5,
160
- 'Reviews' => 150
161
+ 'Reviews' => 150,
162
+ 'Msgs' => 5
161
163
  }
162
164
  data.each do |u, ms|
163
165
  score = ms.map do |t, h|
@@ -169,11 +171,15 @@ def build_xml(opts, loog)
169
171
  averages = {
170
172
  'HpP': {
171
173
  f: lambda { |ms| div(actual(ms['HoC']), actual(ms['Pulls'])) },
172
- title: 'HoC per Pull'
174
+ title: 'HoC per Pull Request'
173
175
  },
174
176
  'HpC': {
175
177
  f: lambda { |ms| div(actual(ms['HoC']), actual(ms['Commits'])) },
176
178
  title: 'HoC per Commit'
179
+ },
180
+ 'MpP': {
181
+ f: lambda { |ms| div(actual(ms['Msgs']), actual(ms['Pulls'])) },
182
+ title: 'Messages per Pull Request'
177
183
  }
178
184
  }
179
185
  data.each do |u, ms|
data/features/cli.feature CHANGED
@@ -15,6 +15,11 @@ Feature: Simple Reporting
15
15
  Then Stdout contains "XML saved to"
16
16
  And Exit code is zero
17
17
 
18
+ Scenario: Simple report through real GitHub API
19
+ When I run bin/cobench with "--coder=yegor256 --include=*/* --days=1 --verbose"
20
+ Then Stdout contains "XML saved to"
21
+ And Exit code is zero
22
+
18
23
  Scenario: Simple report with defaults
19
24
  Given I have a ".cobench" file with content:
20
25
  """
data/lib/cobench/match.rb CHANGED
@@ -31,11 +31,11 @@ class Cobench::Match
31
31
  end
32
32
 
33
33
  def matches?(repo)
34
- if !@opts[:include].empty? && @opts[:include].none? { |m| Cobench::Mask.new(m).matches?(repo) }
34
+ if @opts[:include] && !@opts[:include].empty? && @opts[:include].none? { |m| Cobench::Mask.new(m).matches?(repo) }
35
35
  @loog.debug("Excluding #{repo} due to lack of --include")
36
36
  return false
37
37
  end
38
- if @opts[:exclude].any? { |m| Cobench::Mask.new(m).matches?(repo) }
38
+ if @opts[:exclude] && @opts[:exclude].any? { |m| Cobench::Mask.new(m).matches?(repo) }
39
39
  @loog.debug("Excluding #{repo} due to --exclude")
40
40
  return false
41
41
  end
@@ -43,7 +43,7 @@ class Cobench::Pulls
43
43
  pr = p.pull_request.url.split('/')[-1]
44
44
  repo = p.repository_url.split('/')[-2..-1].join('/')
45
45
  next unless Cobench::Match.new(@opts, loog).matches?(repo)
46
- orgs += p.repository_url.split('/')[-2]
46
+ orgs << p.repository_url.split('/')[-2]
47
47
  pr_json = @api.pull_request(repo, pr)
48
48
  hocs = pr_json.additions + pr_json.deletions
49
49
  hoc += hocs
@@ -37,17 +37,25 @@ class Cobench::Reviews
37
37
  q = "reviewed-by:#{@user} merged:>#{from}"
38
38
  json = @api.search_issues(q)
39
39
  loog.debug("Found #{json.total_count} reviews")
40
+ msgs = 0
40
41
  total = json.items.count do |p|
41
42
  pr = p.pull_request.url.split('/')[-1]
42
43
  repo = p.repository_url.split('/')[-2..-1].join('/')
43
44
  next unless Cobench::Match.new(@opts, loog).matches?(repo)
44
- loog.debug("Including #{repo}##{pr} reviewed by #{@user}")
45
+ loog.debug("Including #{repo}##{pr} reviewed by @#{@user}")
46
+ posted = @api.pull_request_comments(repo, pr).count { |c| c[:user][:login].downcase == @user }
47
+ loog.debug("#{posted} messages posted by @#{@user} to #{repo}##{pr}")
48
+ msgs += posted
45
49
  end
46
50
  [
47
51
  {
48
52
  title: 'Reviews',
49
53
  total: total,
50
54
  href: Iri.new('https://github.com/search').add(q: q)
55
+ },
56
+ {
57
+ title: 'Msgs',
58
+ total: msgs
51
59
  }
52
60
  ]
53
61
  end
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2022 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Cobench
26
- VERSION = '0.0.31'.freeze
26
+ VERSION = '0.0.34'.freeze
27
27
  end
@@ -0,0 +1,37 @@
1
+ # Copyright (c) 2022 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'minitest/autorun'
22
+ require 'octokit'
23
+ require 'loog'
24
+ require_relative '../../lib/cobench/metrics/reviews'
25
+
26
+ # Test for Reviews.
27
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
+ # Copyright:: Copyright (c) 2022 Yegor Bugayenko
29
+ # License:: MIT
30
+ class TestReviews < Minitest::Test
31
+ def test_real
32
+ api = Octokit::Client.new
33
+ m = Cobench::Reviews.new(api, 'graur', { days: 2 })
34
+ ms = m.take(Loog::VERBOSE)
35
+ assert !ms.empty?
36
+ end
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -272,6 +272,7 @@ files:
272
272
  - lib/cobench/metrics/reviews.rb
273
273
  - lib/cobench/version.rb
274
274
  - logo.svg
275
+ - test/metrics/test_reviews.rb
275
276
  - test/test__helper.rb
276
277
  - test/test_mask.rb
277
278
  - test/test_match.rb