gitalytics 1.3.1 → 1.4.0
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 +5 -5
- data/CHANGELOG.md +19 -0
- data/Gemfile +7 -4
- data/README.md +70 -29
- data/Rakefile +3 -1
- data/assets/report.html.erb +295 -0
- data/bin/gitalytics +42 -7
- data/gitalytics.gemspec +10 -13
- data/lib/gitalytics/cli_report.rb +160 -0
- data/lib/gitalytics/cli_text.rb +40 -0
- data/lib/gitalytics/commit.rb +7 -5
- data/lib/gitalytics/git_error.rb +6 -0
- data/lib/gitalytics/gitlog.rb +111 -49
- data/lib/gitalytics/json_report.rb +54 -0
- data/lib/gitalytics/report.rb +302 -0
- data/lib/gitalytics/user.rb +16 -16
- data/lib/gitalytics/version.rb +3 -1
- data/lib/gitalytics.rb +33 -39
- metadata +22 -111
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -16
- data/.travis.yml +0 -5
- data/Gemfile.lock +0 -51
- data/assets/_authors.html.haml +0 -50
- data/assets/_commits.html.haml +0 -21
- data/assets/_css.html.haml +0 -190
- data/assets/_dashboard.html.haml +0 -45
- data/assets/_dates.html.haml +0 -24
- data/assets/_javascript.html.haml +0 -44
- data/assets/gitalytics.html.haml +0 -63
- data/lib/haml_helper.rb +0 -8
- data/test/files/block1 +0 -4
- data/test/files/block2 +0 -4
- data/test/files/block3 +0 -7
- data/test/files/git_log +0 -15
- data/test/lib/test_commit.rb +0 -31
- data/test/lib/test_gitlog.rb +0 -80
- data/test/lib/test_user.rb +0 -97
- data/test/test_helper.rb +0 -2
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'date'
|
|
4
|
+
require 'erb'
|
|
5
|
+
|
|
6
|
+
module Gitalytics
|
|
7
|
+
# Builds the data behind the HTML report and renders it into a single,
|
|
8
|
+
# self-contained HTML page (no external CSS/JS, charts are inline SVG).
|
|
9
|
+
class Report
|
|
10
|
+
include ERB::Util
|
|
11
|
+
|
|
12
|
+
TEMPLATE = File.expand_path('../../assets/report.html.erb', __dir__)
|
|
13
|
+
|
|
14
|
+
# Categorical palette for the top authors; everyone else shares OTHER_COLOR.
|
|
15
|
+
PALETTE = %w[#4f6bed #e8743b #19a979 #ed4a7b #945ecf #13a4b4 #d6a419 #6c8893].freeze
|
|
16
|
+
OTHER_COLOR = '#a3abb8'
|
|
17
|
+
AUTHORS_SHOWN = 15
|
|
18
|
+
|
|
19
|
+
attr_reader :users, :commits, :repo_name, :generated_at
|
|
20
|
+
|
|
21
|
+
def initialize(users:, commits:, repo_name: 'repository', generated_at: Time.now)
|
|
22
|
+
@users = users.reject { |u| u.commits.empty? }
|
|
23
|
+
.sort_by { |u| [-u.commits.size, u.name.to_s] }
|
|
24
|
+
@commits = commits.sort_by(&:time)
|
|
25
|
+
@repo_name = repo_name
|
|
26
|
+
@generated_at = generated_at
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def render
|
|
30
|
+
ERB.new(File.read(TEMPLATE, encoding: 'UTF-8'), trim_mode: '-').result(binding)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def empty?
|
|
34
|
+
commits.empty?
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# ---- Totals -----------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
def first_commit
|
|
40
|
+
commits.first
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def last_commit
|
|
44
|
+
commits.last
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def total_insertions
|
|
48
|
+
@total_insertions ||= commits.sum(&:insertions)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def total_deletions
|
|
52
|
+
@total_deletions ||= commits.sum(&:deletions)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def files_touched
|
|
56
|
+
@files_touched ||= commits.flat_map(&:files_committed).uniq.size
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def active_days
|
|
60
|
+
@active_days ||= commits.map(&:date).uniq.size
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def span_days
|
|
64
|
+
(last_commit.date - first_commit.date).to_i + 1
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def longest_streak
|
|
68
|
+
@longest_streak ||= begin
|
|
69
|
+
best = run = 0
|
|
70
|
+
prev = nil
|
|
71
|
+
commits.map(&:date).uniq.sort.each do |d|
|
|
72
|
+
run = prev && d == prev + 1 ? run + 1 : 1
|
|
73
|
+
best = run if run > best
|
|
74
|
+
prev = d
|
|
75
|
+
end
|
|
76
|
+
best
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def busiest_day
|
|
81
|
+
@busiest_day ||= commits.group_by(&:date).max_by { |d, cs| [cs.size, d] }
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# ---- Authors ----------------------------------------------------------
|
|
85
|
+
|
|
86
|
+
def color_for(user)
|
|
87
|
+
idx = users.index(user)
|
|
88
|
+
idx && idx < PALETTE.size ? PALETTE[idx] : OTHER_COLOR
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def share(user)
|
|
92
|
+
return 0 if commits.empty?
|
|
93
|
+
|
|
94
|
+
(user.commits.size * 100.0 / commits.size)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# ---- Timeline ---------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
# :week for histories shorter than ~18 months, :month otherwise.
|
|
100
|
+
def bucket_unit
|
|
101
|
+
span_days > 540 ? :month : :week
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def bucket_start(date)
|
|
105
|
+
if bucket_unit == :month
|
|
106
|
+
Date.new(date.year, date.month, 1)
|
|
107
|
+
else
|
|
108
|
+
date - ((date.wday - 1) % 7) # Monday
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def buckets
|
|
113
|
+
@buckets ||= begin
|
|
114
|
+
list = []
|
|
115
|
+
cursor = bucket_start(first_commit.date)
|
|
116
|
+
last = bucket_start(last_commit.date)
|
|
117
|
+
while cursor <= last
|
|
118
|
+
list << cursor
|
|
119
|
+
cursor = bucket_unit == :month ? cursor >> 1 : cursor + 7
|
|
120
|
+
end
|
|
121
|
+
list
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def timeline(list = commits)
|
|
126
|
+
counts = Hash.new(0)
|
|
127
|
+
list.each { |c| counts[bucket_start(c.date)] += 1 }
|
|
128
|
+
buckets.map { |b| [b, counts[b]] }
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def bucket_label(date)
|
|
132
|
+
bucket_unit == :month ? date.strftime('%b %Y') : "Week of #{date.strftime('%b %-d, %Y')}"
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# ---- Punch card ---------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
# 7 x 24 matrix of commit counts, rows Monday..Sunday.
|
|
138
|
+
def punch_card
|
|
139
|
+
@punch_card ||= begin
|
|
140
|
+
grid = Array.new(7) { Array.new(24, 0) }
|
|
141
|
+
commits.each { |c| grid[(c.time.wday - 1) % 7][c.time.hour] += 1 }
|
|
142
|
+
grid
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def weekday_totals
|
|
147
|
+
punch_card.map(&:sum)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# ---- Files ------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
def top_files(limit = 10)
|
|
153
|
+
stats = Hash.new { |h, k| h[k] = { commits: 0, insertions: 0, deletions: 0 } }
|
|
154
|
+
commits.each do |c|
|
|
155
|
+
c.summary.each do |s|
|
|
156
|
+
f = stats[s[:filename]]
|
|
157
|
+
f[:commits] += 1
|
|
158
|
+
f[:insertions] += s[:insertions]
|
|
159
|
+
f[:deletions] += s[:deletions]
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
stats.sort_by { |name, s| [-(s[:insertions] + s[:deletions]), name] }.first(limit)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def top_directories(limit = 8)
|
|
166
|
+
churn = Hash.new(0)
|
|
167
|
+
commits.each do |c|
|
|
168
|
+
c.summary.each do |s|
|
|
169
|
+
dir = s[:filename].include?('/') ? "#{s[:filename].split('/').first}/" : '(root)'
|
|
170
|
+
churn[dir] += s[:insertions] + s[:deletions]
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
churn.sort_by { |d, n| [-n, d] }.first(limit)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# ---- Messages ---------------------------------------------------------
|
|
177
|
+
|
|
178
|
+
def shortest_message
|
|
179
|
+
commits.reject { |c| c.subject.to_s.strip.empty? }.min_by { |c| c.subject.length }
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def longest_message
|
|
183
|
+
commits.max_by { |c| c.subject.to_s.length }
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# ---- Formatting / SVG helpers ----------------------------------------
|
|
187
|
+
|
|
188
|
+
def num(value)
|
|
189
|
+
value.to_i.to_s.reverse.scan(/\d{1,3}/).join(',').reverse
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def fmt_date(date)
|
|
193
|
+
date.strftime('%b %-d, %Y')
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
def plural(count, word)
|
|
197
|
+
"#{num(count)} #{count == 1 ? word : "#{word}s"}"
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def timeline_svg(width: 960, height: 220)
|
|
201
|
+
data = timeline
|
|
202
|
+
max = [data.map(&:last).max, 1].max
|
|
203
|
+
pad_l = 36
|
|
204
|
+
pad_b = 24
|
|
205
|
+
plot_w = width - pad_l
|
|
206
|
+
plot_h = height - pad_b - 8
|
|
207
|
+
slot = plot_w.to_f / data.size
|
|
208
|
+
bar_w = [slot - (slot > 4 ? 2 : 0.5), 1].max
|
|
209
|
+
|
|
210
|
+
parts = []
|
|
211
|
+
ticks(max).each do |t|
|
|
212
|
+
y = 8 + plot_h - (t * plot_h / max.to_f)
|
|
213
|
+
parts << %(<line class="grid" x1="#{pad_l}" x2="#{width}" y1="#{y.round(1)}" y2="#{y.round(1)}"/>)
|
|
214
|
+
parts << %(<text class="axis" x="#{pad_l - 6}" y="#{(y + 4).round(1)}" text-anchor="end">#{t}</text>)
|
|
215
|
+
end
|
|
216
|
+
data.each_with_index do |(bucket, count), i|
|
|
217
|
+
x = pad_l + (i * slot)
|
|
218
|
+
h = count * plot_h / max.to_f
|
|
219
|
+
y = 8 + plot_h - h
|
|
220
|
+
title = h("#{bucket_label(bucket)}: #{plural(count, 'commit')}")
|
|
221
|
+
parts << %(<rect class="bar" x="#{x.round(2)}" y="#{y.round(2)}" width="#{bar_w.round(2)}" height="#{[h,
|
|
222
|
+
0].max.round(2)}" rx="1.5"><title>#{title}</title></rect>)
|
|
223
|
+
end
|
|
224
|
+
label_years(data).each do |i, text|
|
|
225
|
+
x = pad_l + (i * slot)
|
|
226
|
+
parts << %(<text class="axis" x="#{x.round(1)}" y="#{height - 6}">#{text}</text>)
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
%(<svg viewBox="0 0 #{width} #{height}" class="chart" role="img" aria-label="Commits over time">#{parts.join}</svg>)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def sparkline_svg(user, width: 96, height: 28)
|
|
233
|
+
data = timeline(user.commits).map(&:last)
|
|
234
|
+
max = [data.max, 1].max
|
|
235
|
+
step = data.size > 1 ? width.to_f / (data.size - 1) : width
|
|
236
|
+
points = data.each_with_index.map do |v, i|
|
|
237
|
+
"#{(i * step).round(1)},#{(height - 2 - (v * (height - 4) / max.to_f)).round(1)}"
|
|
238
|
+
end
|
|
239
|
+
points = ["0,#{height - 2}", "#{width},#{height - 2}"] if data.size < 2
|
|
240
|
+
color = color_for(user)
|
|
241
|
+
%(<svg viewBox="0 0 #{width} #{height}" class="spark" aria-hidden="true"><polyline points="#{points.join(' ')}" fill="none" stroke="#{color}" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round"/></svg>)
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def punch_card_svg(width: 960)
|
|
245
|
+
cell = (width - 48) / 24.0
|
|
246
|
+
r_max = cell * 0.42
|
|
247
|
+
height = ((cell * 7) + 22).round
|
|
248
|
+
max = [punch_card.flatten.max, 1].max
|
|
249
|
+
days = %w[Mon Tue Wed Thu Fri Sat Sun]
|
|
250
|
+
parts = []
|
|
251
|
+
punch_card.each_with_index do |row, d|
|
|
252
|
+
cy = (d * cell) + (cell / 2)
|
|
253
|
+
parts << %(<text class="axis" x="40" y="#{(cy + 4).round(1)}" text-anchor="end">#{days[d]}</text>)
|
|
254
|
+
row.each_with_index do |count, hr|
|
|
255
|
+
cx = 48 + (hr * cell) + (cell / 2)
|
|
256
|
+
r = count.zero? ? 1.5 : [Math.sqrt(count / max.to_f) * r_max, 2.5].max
|
|
257
|
+
cls = count.zero? ? 'dot empty' : 'dot'
|
|
258
|
+
title = h("#{days[d]} #{format('%02d:00', hr)}: #{plural(count, 'commit')}")
|
|
259
|
+
parts << %(<circle class="#{cls}" cx="#{cx.round(1)}" cy="#{cy.round(1)}" r="#{r.round(2)}"><title>#{title}</title></circle>)
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
[0, 6, 12, 18, 23].each do |hr|
|
|
263
|
+
cx = 48 + (hr * cell) + (cell / 2)
|
|
264
|
+
parts << %(<text class="axis" x="#{cx.round(1)}" y="#{height - 4}" text-anchor="middle">#{format('%02d',
|
|
265
|
+
hr)}h</text>)
|
|
266
|
+
end
|
|
267
|
+
%(<svg viewBox="0 0 #{width} #{height}" class="chart" role="img" aria-label="Commits by weekday and hour">#{parts.join}</svg>)
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
private
|
|
271
|
+
|
|
272
|
+
def ticks(max)
|
|
273
|
+
step = nice_step(max / 3.0)
|
|
274
|
+
(1..(max / step)).map { |i| i * step }
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def nice_step(raw)
|
|
278
|
+
return 1 if raw <= 1
|
|
279
|
+
|
|
280
|
+
mag = 10**Math.log10(raw).floor
|
|
281
|
+
[1, 2, 5, 10].map { |m| m * mag }.find { |s| s >= raw }
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
def label_years(data)
|
|
285
|
+
seen = {}
|
|
286
|
+
labels = data.each_with_index.filter_map do |(bucket, _), i|
|
|
287
|
+
next if seen[bucket.year]
|
|
288
|
+
|
|
289
|
+
seen[bucket.year] = true
|
|
290
|
+
[i, bucket.year.to_s]
|
|
291
|
+
end
|
|
292
|
+
thin_labels(labels, data.size)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
# Keep year labels from colliding on long histories.
|
|
296
|
+
def thin_labels(labels, total)
|
|
297
|
+
min_gap = (total / 12.0).ceil
|
|
298
|
+
last = -min_gap
|
|
299
|
+
labels.select { |i, _| (i - last >= min_gap).tap { |ok| last = i if ok } }
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
end
|
data/lib/gitalytics/user.rb
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'digest/md5'
|
|
3
4
|
|
|
4
5
|
class User
|
|
5
|
-
attr_accessor :name, :email, :commits
|
|
6
|
+
attr_accessor :name, :email, :commits
|
|
6
7
|
|
|
7
8
|
def initialize(name, email)
|
|
8
9
|
self.name = name
|
|
9
10
|
self.email = email
|
|
10
11
|
self.commits = []
|
|
11
|
-
self.colors = ColorGenerator.new(saturation: 0.3, lightness: 0.75)
|
|
12
|
-
.create_rgb
|
|
13
|
-
.join(', ')
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
def gravatar
|
|
17
|
-
Digest::MD5.hexdigest(email)
|
|
15
|
+
Digest::MD5.hexdigest(email.to_s.strip.downcase)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def initials
|
|
19
|
+
parts = name.to_s.split(/[\s._-]+/).reject(&:empty?)
|
|
20
|
+
letters = parts.size > 1 ? [parts.first[0], parts.last[0]] : [name.to_s[0, 2]]
|
|
21
|
+
letters.join.upcase
|
|
18
22
|
end
|
|
19
23
|
|
|
20
24
|
def first_commit
|
|
21
|
-
commits.min_by(&:
|
|
25
|
+
commits.min_by(&:time)
|
|
22
26
|
end
|
|
23
27
|
|
|
24
28
|
def last_commit
|
|
25
|
-
commits.max_by(&:
|
|
29
|
+
commits.max_by(&:time)
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
def commits_period
|
|
@@ -34,11 +38,11 @@ class User
|
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
def total_insertions
|
|
37
|
-
commits.
|
|
41
|
+
commits.sum(&:insertions)
|
|
38
42
|
end
|
|
39
43
|
|
|
40
44
|
def total_deletions
|
|
41
|
-
commits.
|
|
45
|
+
commits.sum(&:deletions)
|
|
42
46
|
end
|
|
43
47
|
|
|
44
48
|
def total_changes
|
|
@@ -46,12 +50,8 @@ class User
|
|
|
46
50
|
end
|
|
47
51
|
|
|
48
52
|
def summary
|
|
49
|
-
"#{name} has made #{commits.count} commits on #{working_days} "\
|
|
50
|
-
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def rgba(opacity = 1)
|
|
54
|
-
"rgba(#{colors}, #{opacity})"
|
|
53
|
+
"#{name} has made #{commits.count} commits on #{working_days} " \
|
|
54
|
+
"separate days during a span of #{commits_period} days."
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def weekday_commits
|
data/lib/gitalytics/version.rb
CHANGED
data/lib/gitalytics.rb
CHANGED
|
@@ -1,67 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require '
|
|
4
|
-
require 'matrix'
|
|
3
|
+
require 'gitalytics/cli_report'
|
|
5
4
|
require 'gitalytics/commit'
|
|
6
5
|
require 'gitalytics/gitlog'
|
|
6
|
+
require 'gitalytics/json_report'
|
|
7
|
+
require 'gitalytics/report'
|
|
7
8
|
require 'gitalytics/user'
|
|
8
9
|
require 'gitalytics/version'
|
|
9
10
|
|
|
10
11
|
module Gitalytics
|
|
11
|
-
OUTPUT_FILE = 'gitalytics_result.html'
|
|
12
|
+
OUTPUT_FILE = 'gitalytics_result.html'
|
|
12
13
|
|
|
13
14
|
module_function
|
|
14
15
|
|
|
15
16
|
def analyze(options)
|
|
16
|
-
data = GitLog.parse_git_log(options[:group_by]
|
|
17
|
+
data = GitLog.parse_git_log(options[:group_by], since: options[:since], until_date: options[:until],
|
|
18
|
+
no_merges: options[:no_merges])
|
|
17
19
|
|
|
18
20
|
case options[:format]
|
|
19
21
|
when 'html'
|
|
20
|
-
output_html_report(data, options
|
|
22
|
+
output_html_report(data, options)
|
|
23
|
+
when 'json'
|
|
24
|
+
puts JsonReport.new(build_report(data)).render
|
|
21
25
|
else
|
|
22
|
-
output_cli_report(data
|
|
26
|
+
output_cli_report(data, options)
|
|
23
27
|
end
|
|
24
28
|
end
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def output_cli_report(users)
|
|
31
|
-
users.each do |user|
|
|
32
|
-
puts user.summary
|
|
33
|
-
end
|
|
30
|
+
def output_cli_report(data, options, io = $stdout)
|
|
31
|
+
color = options.fetch(:color) { CliReport.color?(io) }
|
|
32
|
+
io.print CliReport.new(build_report(data), color: color, width: CliReport.width_for(io),
|
|
33
|
+
top: options.fetch(:top, CliReport::DEFAULT_TOP)).render
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
def
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
weekday_commits = @users.map(&:weekday_commits)
|
|
40
|
-
@weekday_commits = weekday_commits.map { |a| Vector[*a] }.inject(:+).to_a
|
|
36
|
+
def repo_name
|
|
37
|
+
top = `git rev-parse --show-toplevel 2>/dev/null`.strip
|
|
38
|
+
File.basename(top.empty? ? Dir.pwd : top)
|
|
41
39
|
end
|
|
42
40
|
|
|
43
|
-
def
|
|
44
|
-
|
|
45
|
-
filepath = File.join(dir, '..', 'assets', 'gitalytics.html.haml')
|
|
46
|
-
File.read(filepath)
|
|
41
|
+
def build_report(data)
|
|
42
|
+
Report.new(users: data[:users], commits: data[:commits], repo_name: repo_name)
|
|
47
43
|
end
|
|
48
44
|
|
|
49
|
-
def output_html_report(data,
|
|
50
|
-
File.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
open_report_in_browser if open_in_browser
|
|
45
|
+
def output_html_report(data, options)
|
|
46
|
+
path = File.expand_path(options[:output] || OUTPUT_FILE)
|
|
47
|
+
File.write(path, build_report(data).render)
|
|
48
|
+
puts "Report written to #{path}"
|
|
49
|
+
open_report_in_browser(path) if options[:browser]
|
|
55
50
|
end
|
|
56
51
|
|
|
57
|
-
def open_report_in_browser
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
end
|
|
52
|
+
def open_report_in_browser(path)
|
|
53
|
+
command =
|
|
54
|
+
case RbConfig::CONFIG['host_os']
|
|
55
|
+
when /mswin|mingw|cygwin/ then %w[cmd /c start]
|
|
56
|
+
when /darwin/ then ['open']
|
|
57
|
+
when /linux|bsd/ then ['xdg-open']
|
|
58
|
+
end
|
|
59
|
+
system(*command, path) if command
|
|
66
60
|
end
|
|
67
61
|
end
|
metadata
CHANGED
|
@@ -1,128 +1,48 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gitalytics
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gonzalo Robaina
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '1.7'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '1.7'
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rake
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '10.0'
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: '10.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: byebug
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: color-generator
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :runtime
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: haml
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - ">="
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0'
|
|
76
|
-
type: :runtime
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - ">="
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0'
|
|
83
|
-
description: Get usefull analytics from your git log
|
|
11
|
+
date: 2026-11-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Commit statistics for any git repository, in your terminal or as a self-contained
|
|
14
|
+
HTML report.
|
|
84
15
|
email: gonzalo@robaina.me
|
|
85
16
|
executables:
|
|
86
17
|
- gitalytics
|
|
87
18
|
extensions: []
|
|
88
19
|
extra_rdoc_files: []
|
|
89
20
|
files:
|
|
90
|
-
- ".coveralls.yml"
|
|
91
|
-
- ".gitignore"
|
|
92
|
-
- ".travis.yml"
|
|
93
21
|
- CHANGELOG.md
|
|
94
22
|
- Gemfile
|
|
95
|
-
- Gemfile.lock
|
|
96
23
|
- README.md
|
|
97
24
|
- Rakefile
|
|
98
|
-
- assets/
|
|
99
|
-
- assets/_commits.html.haml
|
|
100
|
-
- assets/_css.html.haml
|
|
101
|
-
- assets/_dashboard.html.haml
|
|
102
|
-
- assets/_dates.html.haml
|
|
103
|
-
- assets/_javascript.html.haml
|
|
104
|
-
- assets/gitalytics.html.haml
|
|
25
|
+
- assets/report.html.erb
|
|
105
26
|
- bin/gitalytics
|
|
106
27
|
- gitalytics.gemspec
|
|
107
28
|
- lib/gitalytics.rb
|
|
29
|
+
- lib/gitalytics/cli_report.rb
|
|
30
|
+
- lib/gitalytics/cli_text.rb
|
|
108
31
|
- lib/gitalytics/commit.rb
|
|
32
|
+
- lib/gitalytics/git_error.rb
|
|
109
33
|
- lib/gitalytics/gitlog.rb
|
|
34
|
+
- lib/gitalytics/json_report.rb
|
|
35
|
+
- lib/gitalytics/report.rb
|
|
110
36
|
- lib/gitalytics/user.rb
|
|
111
37
|
- lib/gitalytics/version.rb
|
|
112
|
-
|
|
113
|
-
- test/files/block1
|
|
114
|
-
- test/files/block2
|
|
115
|
-
- test/files/block3
|
|
116
|
-
- test/files/git_log
|
|
117
|
-
- test/lib/test_commit.rb
|
|
118
|
-
- test/lib/test_gitlog.rb
|
|
119
|
-
- test/lib/test_user.rb
|
|
120
|
-
- test/test_helper.rb
|
|
121
|
-
homepage: http://gonza.uy/gitalytics
|
|
38
|
+
homepage: https://github.com/pepito2k/gitalytics
|
|
122
39
|
licenses:
|
|
123
40
|
- MIT
|
|
124
|
-
metadata:
|
|
125
|
-
|
|
41
|
+
metadata:
|
|
42
|
+
rubygems_mfa_required: 'true'
|
|
43
|
+
changelog_uri: https://github.com/pepito2k/gitalytics/blob/master/CHANGELOG.md
|
|
44
|
+
source_code_uri: https://github.com/pepito2k/gitalytics
|
|
45
|
+
post_install_message:
|
|
126
46
|
rdoc_options: []
|
|
127
47
|
require_paths:
|
|
128
48
|
- lib
|
|
@@ -130,24 +50,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
130
50
|
requirements:
|
|
131
51
|
- - ">="
|
|
132
52
|
- !ruby/object:Gem::Version
|
|
133
|
-
version:
|
|
53
|
+
version: '3.1'
|
|
134
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
55
|
requirements:
|
|
136
56
|
- - ">="
|
|
137
57
|
- !ruby/object:Gem::Version
|
|
138
58
|
version: '0'
|
|
139
59
|
requirements: []
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
signing_key:
|
|
60
|
+
rubygems_version: 3.4.10
|
|
61
|
+
signing_key:
|
|
143
62
|
specification_version: 4
|
|
144
63
|
summary: Git Analytics
|
|
145
|
-
test_files:
|
|
146
|
-
- test/files/block1
|
|
147
|
-
- test/files/block2
|
|
148
|
-
- test/files/block3
|
|
149
|
-
- test/files/git_log
|
|
150
|
-
- test/lib/test_commit.rb
|
|
151
|
-
- test/lib/test_gitlog.rb
|
|
152
|
-
- test/lib/test_user.rb
|
|
153
|
-
- test/test_helper.rb
|
|
64
|
+
test_files: []
|
data/.coveralls.yml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
service_name: travis-ci
|
data/.gitignore
DELETED