cobench 0.0.15 → 0.0.18

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: afc414be5da28bf1b4703b1a9b7783dafd90594c42dcf6692102f05030af39a0
4
- data.tar.gz: 1fdabac9c6c9e1d6179b8c6d6995ee2579d7949111a2c12f24027aa9ecda7c0d
3
+ metadata.gz: 5ebe9e177a3dbecdb610079242b819c7f35188a15ea362f9b14b2f3f4d5b7d87
4
+ data.tar.gz: b17a94e0a3ea2f9f57184860f7747ebe232b2ea7af19a42ebb81dea59d4b29c9
5
5
  SHA512:
6
- metadata.gz: 5997a605602bb82a900cbb4cc3cc44fa15bfff5333248a8d54eb437897e5caa0ebcf9875a14127cef2ee348bf1f8b395c6fa8f27f6809a356df7e7ba7c9110f7
7
- data.tar.gz: 89d955def9ee96a4965e28083e867ba5e30908f9a956f9825296be7111da91669d6d98e077150d2953d52c25b22571299958225a991f09e31b01a2c2f5e2a2f3
6
+ metadata.gz: 8c891cf36011771f14f89c2b762ea57ce53d44af35d3fcbb8033fef402453ed1f7911ed191f243492c2ac4d83ae2e6c32079a3a454a35bdaaa5888fefbc20a08
7
+ data.tar.gz: 072a7bb771a409c753be6a1027f024d72cd887eddf3c5a6ec02c992e04ae4ce0dd7f39ef9b41437cc0bf607e49965748548edc39b92534fb1a06c37ff121b9e6
data/.rultor.yml CHANGED
@@ -1,3 +1,5 @@
1
+ docker:
2
+ image: yegor256/rultor-image:1.9.1
1
3
  assets:
2
4
  rubygems.yml: yegor256/home#assets/rubygems.yml
3
5
  install: |
@@ -16,7 +18,3 @@ release:
16
18
  merge:
17
19
  script: |-
18
20
  bundle exec rake
19
- deploy:
20
- script: |-
21
- echo "There is nothing to deploy"
22
- exit -1
data/assets/index.xsl CHANGED
@@ -50,6 +50,9 @@ SOFTWARE.
50
50
  header { text-align: center; }
51
51
  footer { text-align: center; font-size: 0.8em; line-height: 1.2em; color: gray; }
52
52
  article { width: 60em; border: 0; }
53
+ td.avatar { vertical-align: middle; text-align: center; }
54
+ td.avatar img { width: 1.5em; height: 1.5em; vertical-align: middle; }
55
+ .subtitle { font-size: 0.8em; line-height: 1em; color: gray; }
53
56
  .sorter { cursor: pointer; }
54
57
  </style>
55
58
  </head>
@@ -57,7 +60,9 @@ SOFTWARE.
57
60
  <section>
58
61
  <header>
59
62
  <p>
60
- <img src="https://raw.githubusercontent.com/yegor256/cobench/master/logo.svg" style="width:64px"/>
63
+ <a href="">
64
+ <img src="https://raw.githubusercontent.com/yegor256/cobench/master/logo.svg" style="width:64px"/>
65
+ </a>
61
66
  </p>
62
67
  </header>
63
68
  <article>
@@ -77,17 +82,17 @@ SOFTWARE.
77
82
  <xsl:text> on </xsl:text>
78
83
  <xsl:value-of select="cobench/@time"/>
79
84
  <xsl:text>. </xsl:text>
80
- <xsl:text>"Commits" is the total number of </xsl:text>
85
+ <xsl:text>"Commits" is the total number of non-merge </xsl:text>
81
86
  <a href="https://github.com/git-guides/git-commit">
82
87
  <xsl:text>Git commits</xsl:text>
83
88
  </a>
84
- <xsl:text> authored by the user. </xsl:text>
85
- <xsl:text>"HoC" is the total number of user's hits of code. </xsl:text>
89
+ <xsl:text> to the default branch, authored by the user. </xsl:text>
90
+ <xsl:text>"HoC" is the total number of user's </xsl:text>
86
91
  <a href="https://www.yegor256.com/2014/11/14/hits-of-code.html">
87
92
  <xsl:text>hits of code</xsl:text>
88
93
  </a>
89
94
  <xsl:text>. </xsl:text>
90
- <xsl:text>"Issues" is the total number of issues. </xsl:text>
95
+ <xsl:text>"Issues" is the total number of issues submitted by the user. </xsl:text>
91
96
  <a href="https://docs.github.com/en/issues">
92
97
  <xsl:text>issues</xsl:text>
93
98
  </a>
@@ -96,12 +101,37 @@ SOFTWARE.
96
101
  <a href="https://docs.github.com/en/pull-requests">
97
102
  <xsl:text>pull requests</xsl:text>
98
103
  </a>
99
- <xsl:text> created by the user and merged. </xsl:text>
100
- <xsl:text>"Score" is an arithmetic summary of all other numbers with multipliers: </xsl:text>
101
- <xsl:text>one Pull costs 100 points, </xsl:text>
102
- <xsl:text>one Issue 50 points, </xsl:text>
103
- <xsl:text>one Commit 5 points, </xsl:text>
104
- <xsl:text>one HoC 1 point.</xsl:text>
104
+ <xsl:text> created by the user and already merged. </xsl:text>
105
+ <xsl:text>"Reviews" is the total number of merged pull requests that were reviewed by the user. </xsl:text>
106
+ <xsl:text>"Score" is an arithmetic summary of all metrics with multipliers: </xsl:text>
107
+ <xsl:for-each select="cobench/weights/w">
108
+ <xsl:if test="position() &gt; 1">
109
+ <xsl:text>, </xsl:text>
110
+ </xsl:if>
111
+ <xsl:text>one </xsl:text>
112
+ <xsl:choose>
113
+ <xsl:when test="substring(@id, string-length(@id)) = 's'">
114
+ <xsl:value-of select="substring(@id, 0, string-length(@id))"/>
115
+ </xsl:when>
116
+ <xsl:otherwise>
117
+ <xsl:value-of select="@id"/>
118
+ </xsl:otherwise>
119
+ </xsl:choose>
120
+ <xsl:choose>
121
+ <xsl:when test="position() = 1">
122
+ <xsl:text> costs </xsl:text>
123
+ </xsl:when>
124
+ <xsl:otherwise>
125
+ <xsl:text> — </xsl:text>
126
+ </xsl:otherwise>
127
+ </xsl:choose>
128
+ <xsl:value-of select="text()"/>
129
+ <xsl:text> point</xsl:text>
130
+ <xsl:if test="text() != '1'">
131
+ <xsl:text>s</xsl:text>
132
+ </xsl:if>
133
+ </xsl:for-each>
134
+ <xsl:text>.</xsl:text>
105
135
  </p>
106
136
  <p>
107
137
  <xsl:text>The numbers you see reflect the activity of the last </xsl:text>
@@ -119,6 +149,7 @@ SOFTWARE.
119
149
  <xsl:template match="cobench/titles">
120
150
  <thead>
121
151
  <tr>
152
+ <th/>
122
153
  <th/>
123
154
  <xsl:for-each select="title[generate-id() = generate-id(key('titles', .)[1])]">
124
155
  <xsl:sort select="."/>
@@ -136,11 +167,18 @@ SOFTWARE.
136
167
  </xsl:template>
137
168
  <xsl:template match="coder">
138
169
  <tr>
170
+ <td class="avatar">
171
+ <img src="https://socatar.com/github/{@id}/64-64"/>
172
+ </td>
139
173
  <td>
140
174
  <a href="https://github.com/{@id}">
141
175
  <xsl:text>@</xsl:text>
142
176
  <xsl:value-of select="@id"/>
143
177
  </a>
178
+ <br/>
179
+ <span class="subtitle">
180
+ <xsl:value-of select="@details"/>
181
+ </span>
144
182
  </td>
145
183
  <xsl:for-each select="metrics/m">
146
184
  <xsl:sort select="@id"/>
data/bin/cobench CHANGED
@@ -127,19 +127,17 @@ begin
127
127
  end
128
128
  end
129
129
  end
130
+ weights = {
131
+ 'HoC' => 1,
132
+ 'Pulls' => 200,
133
+ 'Issues' => 50,
134
+ 'Commits' => 5,
135
+ 'Reviews' => 75
136
+ }
130
137
  data.each do |u, ms|
131
138
  score = ms.map do |t, h|
132
- h[:total] * if t == 'HoC'
133
- 1
134
- elsif t == 'Pulls'
135
- 100
136
- elsif t == 'Issues'
137
- 50
138
- elsif t == 'Commits'
139
- 5
140
- else
141
- raise "Unknown title '#{t}'"
142
- end
139
+ raise "Unknown title '#{t}'" unless weights.key?(t)
140
+ h[:total] * weights[t]
143
141
  end.inject(0, :+)
144
142
  data[u]['Score'] = { total: score, href: '' }
145
143
  end
@@ -150,9 +148,16 @@ begin
150
148
  xml.title t
151
149
  end
152
150
  end
151
+ xml.weights do
152
+ weights.each do |t, w|
153
+ xml.w(id: t) do
154
+ xml.text w
155
+ end
156
+ end
157
+ end
153
158
  xml.coders do
154
159
  data.each do |u, ms|
155
- xml.coder(id: u) do
160
+ xml.coder(id: u, details: api.user(u).name) do
156
161
  xml.metrics do
157
162
  ms.each do |k, v|
158
163
  xml.m(id: k, href: v[:href]) do
data/features/cli.feature CHANGED
@@ -15,3 +15,14 @@ Feature: Simple Reporting
15
15
  Then Stdout contains "XML saved to"
16
16
  And Exit code is zero
17
17
 
18
+ Scenario: Simple report with defaults
19
+ Given I have a ".cobench" file with content:
20
+ """
21
+ --verbose
22
+
23
+ --coder=john
24
+ """
25
+ When I run bin/cobench with "--dry"
26
+ Then Stdout contains "XML saved to"
27
+ And Exit code is zero
28
+
@@ -34,7 +34,7 @@ class Cobench::Commits
34
34
 
35
35
  def take(loog)
36
36
  from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
37
- q = "author:#{@user} author-date:>#{from}"
37
+ q = "author:#{@user} author-date:>#{from} is:public merge:false"
38
38
  json = @api.search_commits(q)
39
39
  loog.debug("Found #{json.total_count} commits")
40
40
  hoc = 0
@@ -44,6 +44,7 @@ class Cobench::Commits
44
44
  next unless Cobench::Match.new(@opts, loog).matches?(repo)
45
45
  loog.debug("Including #{sha} in #{repo}")
46
46
  json = @api.commit(repo, sha)
47
+ next unless json
47
48
  hocs = json.stats.total
48
49
  loog.debug("Found #{hocs} HoC in #{sha}")
49
50
  hoc += hocs
@@ -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 closed:>#{from}"
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
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2022 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Cobench
26
- VERSION = '0.0.15'.freeze
26
+ VERSION = '0.0.18'.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.15
4
+ version: 0.0.18
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-08-15 00:00:00.000000000 Z
11
+ date: 2022-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -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