cobench 0.0.38 → 0.0.40

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: 581c5998a978db8683fa8e675b8e293aa5b66f75a37ec52e72fabc92994c4e8b
4
- data.tar.gz: 76b7dd517e81bdd4011d294f3a325e4b9bc271a6130fedb8c3d36c97aac49f5e
3
+ metadata.gz: e8dad898dc02a5e517e24c6fe0b0a8e3ff7d4e06de2e0f732956bb350bc1ea26
4
+ data.tar.gz: 4e1a29fc050bafb9d3a8c203fce03a58cfbb4687f9c2b4034faddcc33f8357de
5
5
  SHA512:
6
- metadata.gz: 85618ec2a17dc04c0d6fadc20547468432fff9daa79e8cf58929a0ad81790328fc9533a8d015010ab164f05b59f23098a795e30c4a8ca14de64f3b39dbdfb901
7
- data.tar.gz: 295d72ce7a9cd87396066e8d0f6831b1bd5830f9ad3311b86723eb1377dd4bb8772bd9bd4f48a3b6789f208313360cc549d6c88cc3c3281e7cf87ce2f4dcaf04
6
+ metadata.gz: 42b9c779e397ce17698bd5285ce8f687834fe757cc2b615148e481bac0157110d9dfd30afb912452cd2dd4339b57f1511260fb0667e78ffdf829fe896bb7f95e
7
+ data.tar.gz: 072c0c7d39ecd51754ae545dfc426a8a8e054cde1fdef7d202859ffd0c858208e9ce00ae0b173f631ca50914ec257990a15b6d8c279efcdf4311d2bc101eb3b6
data/assets/index.xsl CHANGED
@@ -154,7 +154,7 @@ SOFTWARE.
154
154
  <xsl:text>issues</xsl:text>
155
155
  </a>
156
156
  <xsl:text>. </xsl:text>
157
- <xsl:text>"Msgs" is the total number of messages posted as a reviewer in pull requests. </xsl:text>
157
+ <xsl:text>"Msgs" is the total number of messages posted in pull requests where the user was a reviewer. </xsl:text>
158
158
  <xsl:text>"Pulls" is the total number of </xsl:text>
159
159
  <a href="https://docs.github.com/en/pull-requests">
160
160
  <xsl:text>pull requests</xsl:text>
@@ -199,7 +199,10 @@ SOFTWARE.
199
199
  <xsl:text>"</xsl:text>
200
200
  <xsl:value-of select="."/>
201
201
  <xsl:text>"</xsl:text>
202
- <xsl:text> stands for </xsl:text>
202
+ <xsl:if test="position() = 1">
203
+ <xsl:text> stands</xsl:text>
204
+ </xsl:if>
205
+ <xsl:text> for </xsl:text>
203
206
  <xsl:value-of select="@subtitle"/>
204
207
  </xsl:for-each>
205
208
  <xsl:text>.</xsl:text>
@@ -331,15 +334,25 @@ SOFTWARE.
331
334
  </tr>
332
335
  </xsl:template>
333
336
  <xsl:template match="m">
337
+ <xsl:variable name="value">
338
+ <xsl:choose>
339
+ <xsl:when test="@hideZero and .='0'">
340
+ <!-- nothing -->
341
+ </xsl:when>
342
+ <xsl:otherwise>
343
+ <xsl:value-of select="."/>
344
+ </xsl:otherwise>
345
+ </xsl:choose>
346
+ </xsl:variable>
334
347
  <xsl:variable name="body">
335
348
  <xsl:choose>
336
349
  <xsl:when test="@href">
337
350
  <a href="{@href}">
338
- <xsl:value-of select="."/>
351
+ <xsl:value-of select="$value"/>
339
352
  </a>
340
353
  </xsl:when>
341
354
  <xsl:otherwise>
342
- <xsl:value-of select="."/>
355
+ <xsl:value-of select="$value"/>
343
356
  </xsl:otherwise>
344
357
  </xsl:choose>
345
358
  </xsl:variable>
data/bin/cobench CHANGED
@@ -80,8 +80,14 @@ def div(a, b)
80
80
  a / b
81
81
  end
82
82
 
83
+ def zero?(ms)
84
+ return true if ms.nil?
85
+ return true if ms.key?(:actual) == 0
86
+ false
87
+ end
88
+
83
89
  def actual(ms)
84
- return 0 if ms.nil?
90
+ return 0 if zero?(ms)
85
91
  return ms[:actual] if ms.key?(:actual)
86
92
  ms[:total]
87
93
  end
@@ -172,24 +178,31 @@ def build_xml(opts, loog)
172
178
  averages = {
173
179
  'CpP': {
174
180
  f: lambda { |ms| div(actual(ms['Commits']), actual(ms['Pulls'])) },
175
- title: 'Commits per Pull Request'
181
+ title: 'Commits per Pull Request',
182
+ hideZero: lambda { |ms| zero?(ms['Commits']) || zero?(ms['Pulls']) }
176
183
  },
177
184
  'HpP': {
178
185
  f: lambda { |ms| div(actual(ms['HoC']), actual(ms['Pulls'])) },
179
- title: 'HoC per Pull Request'
186
+ title: 'HoC per Pull Request',
187
+ hideZero: lambda { |ms| zero?(ms['HoC']) || zero?(ms['Pulls']) }
180
188
  },
181
189
  'HpC': {
182
190
  f: lambda { |ms| div(actual(ms['HoC']), actual(ms['Commits'])) },
183
- title: 'HoC per Commit'
191
+ title: 'HoC per Commit',
192
+ hideZero: lambda { |ms| zero?(ms['HoC']) || zero?(ms['Commits']) }
184
193
  },
185
194
  'MpRP': {
186
195
  f: lambda { |ms| div(actual(ms['Msgs']), actual(ms['Reviews']) + actual(ms['Pulls'])) },
187
- title: 'Messages per Review+Pulls'
196
+ title: 'Messages per Review+Pulls',
197
+ hideZero: lambda { |ms| zero?(ms['Msgs']) || (zero?(ms['Reviews']) && zero?(ms['Pulls'])) }
188
198
  }
189
199
  }
190
200
  data.each do |u, ms|
191
201
  averages.each do |k, a|
192
- data[u][k] = { total: a[:f].call(ms) }
202
+ data[u][k] = {
203
+ total: a[:f].call(ms),
204
+ hideZero: a[:hideZero].call(ms),
205
+ }
193
206
  end
194
207
  end
195
208
  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
@@ -243,6 +256,7 @@ def build_xml(opts, loog)
243
256
  xml.m(id: k) do
244
257
  xml.parent.set_attribute('actual', v[:actual]) unless v[:actual].nil?
245
258
  xml.parent.set_attribute('href', v[:href]) unless v[:href].nil?
259
+ xml.parent.set_attribute('hideZero', 'yes') unless v[:hideZero].nil? || !v[:hideZero]
246
260
  xml.text v[:total]
247
261
  end
248
262
  end
@@ -44,6 +44,7 @@ class Cobench::Reviews
44
44
  next unless Cobench::Match.new(@opts, loog).matches?(repo)
45
45
  loog.debug("Including #{repo}##{pr} reviewed by @#{@user}")
46
46
  posted = @api.pull_request_comments(repo, pr).count { |c| c[:user][:login].downcase == @user }
47
+ posted += @api.issue_comments(repo, pr).count { |c| c[:user][:login].downcase == @user }
47
48
  loog.debug("#{posted} messages posted by @#{@user} to #{repo}##{pr}")
48
49
  msgs += posted
49
50
  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.38'.freeze
26
+ VERSION = '0.0.40'.freeze
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.38
4
+ version: 0.0.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-21 00:00:00.000000000 Z
11
+ date: 2022-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace