cobench 0.0.33 → 0.0.34

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e826b27c5e0587f100676d206c255ab1a49dd031218a983949641434d742642b
4
- data.tar.gz: 3f940d517efae58c02800681ce181fce837ea4d33bf6a6698833f808856bfa0a
3
+ metadata.gz: bde636a5d9fea9b6b334d82f9333608b806bfe9479b16bddf742e8718e6c5e4a
4
+ data.tar.gz: 2cd0411ce9b5d13016e81998fb971da4c7eb6975c69f74758b0400c727f1be5b
5
5
  SHA512:
6
- metadata.gz: 2f89fe625b2e9ad37e2f94ec370af8e45552dfcce768a1dea6b583714994ecd119493d7f65113c5cc8262f7e81ed86951ce49f06970929b0b611a7225ce98186
7
- data.tar.gz: cb4a616c54c4fba0109a6bd36592f2377896793de5ff05b7ba1ea228d77b89eeccf39962d5ba09af5d94168fc25e103d4809344c1b747a9a96d673305779fc41
6
+ metadata.gz: 29ab01d89a72192c4b0e20e8e0ae6239fc65268ad18c65c593a74f8646eef0d9e1802d74b87b77389322a029087d794fff9917a4a35a166d0c2bfe7e13938d0e
7
+ data.tar.gz: ad5f1d829346f084a69efb40b77841173128121f4f62cf5f98f2951235fb9bbe5f95db1574ec82b1599a18b7c74cde659e45958b2f92132963082cd53f5d9821
data/assets/index.xsl CHANGED
@@ -144,6 +144,7 @@ SOFTWARE.
144
144
  <xsl:text>issues</xsl:text>
145
145
  </a>
146
146
  <xsl:text>. </xsl:text>
147
+ <xsl:text>"Msgs" is the total number of messages posted as a reviewer in pull requests. </xsl:text>
147
148
  <xsl:text>"Pulls" is the total number of </xsl:text>
148
149
  <a href="https://docs.github.com/en/pull-requests">
149
150
  <xsl:text>pull requests</xsl:text>
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/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
@@ -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.33'.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.33
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