cobench 0.0.13 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/index.xsl +2 -0
- data/bin/cobench +12 -9
- data/features/cli.feature +1 -1
- data/lib/cobench/mask.rb +2 -2
- data/lib/cobench/metrics/pulls.rb +1 -1
- data/lib/cobench/metrics/reviews.rb +54 -0
- data/lib/cobench/version.rb +1 -1
- data/test/test_mask.rb +2 -2
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48f017fb5f4994354ad835b809870f6c804bf3350cd22b443e29f2dfda0f1276
|
4
|
+
data.tar.gz: a57ba22b48e7760415921e4c80fb52c407e95ad84c1c3d5da4e1b2de76538f5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 845946fc2dfb68de3ef780a35b2063311e38104f337a235067f88d2ab00bf3b309e30025e1bb3dd2091ca2d43af80e18a8332258f6085dedf96f9f3de39889ef
|
7
|
+
data.tar.gz: 9133dcf17b4d1ca286e70c46b122dfd458c6bce44f1f247bae74a4b5b7604db34c90a74493eb5ac49a05fa74626c5ab5ee14f09751d23ec5143052122173b5e6
|
data/assets/index.xsl
CHANGED
@@ -97,9 +97,11 @@ SOFTWARE.
|
|
97
97
|
<xsl:text>pull requests</xsl:text>
|
98
98
|
</a>
|
99
99
|
<xsl:text> created by the user and merged. </xsl:text>
|
100
|
+
<xsl:text>"Reviews" is the total number of merged pull requests reviewed by the user. </xsl:text>
|
100
101
|
<xsl:text>"Score" is an arithmetic summary of all other numbers with multipliers: </xsl:text>
|
101
102
|
<xsl:text>one Pull costs 100 points, </xsl:text>
|
102
103
|
<xsl:text>one Issue 50 points, </xsl:text>
|
104
|
+
<xsl:text>one Review 40 points, </xsl:text>
|
103
105
|
<xsl:text>one Commit 5 points, </xsl:text>
|
104
106
|
<xsl:text>one HoC 1 point.</xsl:text>
|
105
107
|
</p>
|
data/bin/cobench
CHANGED
@@ -56,7 +56,7 @@ opts = Slop.parse(args, strict: true, help: true) do |o|
|
|
56
56
|
o.array '--exclude', 'Mask of GitHub repo to exclude'
|
57
57
|
end
|
58
58
|
|
59
|
-
if opts.help?
|
59
|
+
if opts.help? || opts[:coder].empty?
|
60
60
|
puts opts
|
61
61
|
exit
|
62
62
|
end
|
@@ -95,18 +95,19 @@ begin
|
|
95
95
|
loog.info("Reading GitHub data for the last #{opts[:days]} days")
|
96
96
|
titles = {}
|
97
97
|
opts[:coder].each do |u|
|
98
|
-
|
99
|
-
|
98
|
+
user = u.downcase
|
99
|
+
loog.info("Scanning #{user}...")
|
100
|
+
data[user] = {}
|
100
101
|
Dir[File.join(__dir__, '../lib/cobench/metrics/*.rb')].each do |f|
|
101
102
|
name = File::basename(f).split('.')[0]
|
102
103
|
if !opts[:metrics].empty? && !opts[:metrics].include?(name)
|
103
|
-
loog.info("Ignoring #{
|
104
|
+
loog.info("Ignoring #{user}/#{name} due to --metrics")
|
104
105
|
next
|
105
106
|
end
|
106
107
|
type = "Cobench::#{name.capitalize}"
|
107
|
-
loog.info("Reading #{
|
108
|
+
loog.info("Reading #{user}/#{name}...")
|
108
109
|
require_relative f
|
109
|
-
m = type.split('::').reduce(Module, :const_get).new(api,
|
110
|
+
m = type.split('::').reduce(Module, :const_get).new(api, user, opts)
|
110
111
|
if opts.dry?
|
111
112
|
measures = [
|
112
113
|
{ title: 'Issues', total: Random.new.rand(100), href: 'https://github.com/' },
|
@@ -119,10 +120,10 @@ begin
|
|
119
120
|
end
|
120
121
|
measures.each do |d|
|
121
122
|
before = 0
|
122
|
-
before += data[
|
123
|
-
data[
|
123
|
+
before += data[user][d[:title]][:total] if data[user][d[:title]] != nil
|
124
|
+
data[user][d[:title]] = { total: d[:total] + before, href: d[:href] }
|
124
125
|
titles[d[:title]] = d[:title]
|
125
|
-
loog.info("The value of #{
|
126
|
+
loog.info("The value of #{user}/#{d[:title]} is #{d[:total]}")
|
126
127
|
end
|
127
128
|
end
|
128
129
|
end
|
@@ -136,6 +137,8 @@ begin
|
|
136
137
|
50
|
137
138
|
elsif t == 'Commits'
|
138
139
|
5
|
140
|
+
elsif t == 'Reviews'
|
141
|
+
40
|
139
142
|
else
|
140
143
|
raise "Unknown title '#{t}'"
|
141
144
|
end
|
data/features/cli.feature
CHANGED
@@ -11,7 +11,7 @@ Feature: Simple Reporting
|
|
11
11
|
Then Exit code is zero
|
12
12
|
|
13
13
|
Scenario: Simple report
|
14
|
-
When I run bin/cobench with "--coder yegor256 --verbose --dry --to foo"
|
14
|
+
When I run bin/cobench with "--coder yegor256 --coder John --verbose --dry --to foo"
|
15
15
|
Then Stdout contains "XML saved to"
|
16
16
|
And Exit code is zero
|
17
17
|
|
data/lib/cobench/mask.rb
CHANGED
@@ -24,11 +24,11 @@
|
|
24
24
|
# License:: MIT
|
25
25
|
class Cobench::Mask
|
26
26
|
def initialize(txt)
|
27
|
-
@org, @repo = txt.split('/')
|
27
|
+
@org, @repo = txt.downcase.split('/')
|
28
28
|
end
|
29
29
|
|
30
30
|
def matches?(repo)
|
31
|
-
org, repo = repo.split('/')
|
31
|
+
org, repo = repo.downcase.split('/')
|
32
32
|
return false if ['', nil].include?(org)
|
33
33
|
return false if ['', nil].include?(repo)
|
34
34
|
return false if org != @org && @org != '*'
|
@@ -34,7 +34,7 @@ class Cobench::Pulls
|
|
34
34
|
|
35
35
|
def take(loog)
|
36
36
|
from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
|
37
|
-
q = "in:comments type:pr author:#{@user} is:merged
|
37
|
+
q = "in:comments type:pr author:#{@user} is:merged merged:>#{from}"
|
38
38
|
json = @api.search_issues(q)
|
39
39
|
loog.debug("Found #{json.total_count} pull requests")
|
40
40
|
hoc = 0
|
@@ -0,0 +1,54 @@
|
|
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 'iri'
|
22
|
+
require_relative '../match'
|
23
|
+
|
24
|
+
# Reviews in GitHub API.
|
25
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
26
|
+
# Copyright:: Copyright (c) 2022 Yegor Bugayenko
|
27
|
+
# License:: MIT
|
28
|
+
class Cobench::Reviews
|
29
|
+
def initialize(api, user, opts)
|
30
|
+
@api = api
|
31
|
+
@user = user
|
32
|
+
@opts = opts
|
33
|
+
end
|
34
|
+
|
35
|
+
def take(loog)
|
36
|
+
from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
|
37
|
+
q = "reviewed-by:#{@user} merged:>#{from}"
|
38
|
+
json = @api.search_issues(q)
|
39
|
+
loog.debug("Found #{json.total_count} reviews")
|
40
|
+
total = json.items.count do |p|
|
41
|
+
pr = p.pull_request.url.split('/')[-1]
|
42
|
+
repo = p.repository_url.split('/')[-2..-1].join('/')
|
43
|
+
next unless Cobench::Match.new(@opts, loog).matches?(repo)
|
44
|
+
loog.debug("Including #{repo}##{pr} reviewed by #{@user}")
|
45
|
+
end
|
46
|
+
[
|
47
|
+
{
|
48
|
+
title: 'Reviews',
|
49
|
+
total: total,
|
50
|
+
href: Iri.new('https://github.com/search').add(q: q)
|
51
|
+
}
|
52
|
+
]
|
53
|
+
end
|
54
|
+
end
|
data/lib/cobench/version.rb
CHANGED
data/test/test_mask.rb
CHANGED
@@ -28,8 +28,8 @@ require_relative '../lib/cobench/mask'
|
|
28
28
|
class TestMask < Minitest::Test
|
29
29
|
def test_positive
|
30
30
|
assert Cobench::Mask.new('*/*').matches?('foo/bar')
|
31
|
-
assert Cobench::Mask.new('test/*').matches?('
|
32
|
-
assert Cobench::Mask.new('test/hello').matches?('test/
|
31
|
+
assert Cobench::Mask.new('test/*').matches?('Test/one')
|
32
|
+
assert Cobench::Mask.new('test/hello').matches?('test/Hello')
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_negative
|
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.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -255,6 +255,7 @@ files:
|
|
255
255
|
- lib/cobench/metrics/commits.rb
|
256
256
|
- lib/cobench/metrics/issues.rb
|
257
257
|
- lib/cobench/metrics/pulls.rb
|
258
|
+
- lib/cobench/metrics/reviews.rb
|
258
259
|
- lib/cobench/version.rb
|
259
260
|
- logo.svg
|
260
261
|
- test/test__helper.rb
|