git-heatmap 0.2.0 → 0.2.1

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: 256be1e25dbb670296b2920019da24a553218a7b8c742c2fd5292ea632e136f4
4
- data.tar.gz: ba835b8d95b1b2ab6416297455f79f899590f6445cebd1ef770eb618f6c8e79f
3
+ metadata.gz: c8764bb0188dcd5f4b9b153940a3a5e074447b418e6de705a95638a013fb8845
4
+ data.tar.gz: 56679e70910bc167fa99c505b48b27247c77c4bb129d2b5d388b3f5ed0ee5250
5
5
  SHA512:
6
- metadata.gz: 726fd85534592c2148a8ec97d5b6f1a1eeb9372fc5fcd62ff1a6f54a00fa840ff3b134b9c07a3d14cf69ee7f0de461a9447087d2adbd8ed1bbb49547ed983c27
7
- data.tar.gz: c626dbf885e982085f21c7c63c09bdcc8665b48fa17d89c6fa714d6931defe6bf192297eec90f24565783e79319bf49c7516d4490d147b0ed5db649ab6700fa3
6
+ metadata.gz: 7bfcdb43d912ee98518ed270dbea47f99ffeca4f68d7c70d403cdd0610ab5d402f594a139ddb1f0149832b8b1022bafe012530f13ad5b4d6a2b7330d210b5348
7
+ data.tar.gz: 5d60ca821d0554f96ff065b9285b0f22d5cd6f048e263aec189e8225efc20ffa52d171122f4cf468d5d18d5eecaeee29d22c70154654a7bc91b93b52593d56bc
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  Visualise git history over time.
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/ioquatix/build.svg)](http://travis-ci.org/ioquatix/build)
5
+ ![A screenshot of the visualisation](Screenshot.png)
6
+
7
+ [![Build Status](https://secure.travis-ci.org/ioquatix/git-heatmap.svg)](http://travis-ci.org/ioquatix/git-heatmap)
6
8
 
7
9
  ## Installation
8
10
 
data/Screenshot.png ADDED
Binary file
@@ -33,6 +33,10 @@ module Git
33
33
  @latest_commit_at = nil
34
34
 
35
35
  @maximum = 0
36
+
37
+ @additions = Hash.new{|h,k| h[k] = 0}
38
+ @deletions = Hash.new{|h,k| h[k] = 0}
39
+ @churn = Hash.new{|h,k| h[k] = 0}
36
40
  end
37
41
 
38
42
  attr :commits
@@ -41,25 +45,38 @@ module Git
41
45
  attr :earliest_commit_at
42
46
  attr :latest_commit_at
43
47
 
48
+ attr :additions
49
+ attr :deletions
50
+ attr :churn
51
+
44
52
  def size
45
53
  @commits.size
46
54
  end
47
55
 
48
56
  attr :maximum
49
57
 
50
- def << commit
51
- return if @commits.include?(commit.oid)
52
-
53
- @commits[commit.oid] = commit
54
-
58
+ def add(commit, patch)
55
59
  author = commit.author
56
60
  time = author[:time]
57
61
  key = @filter.key(time)
58
- commits = (@periods[key] ||= [])
59
- commits << commit
60
62
 
61
- if commits.size > @maximum
62
- @maximum = commits.size
63
+ unless @commits.include?(commit.oid)
64
+ @commits[commit.oid] = commit
65
+
66
+ commits = (@periods[key] ||= [])
67
+ commits << commit
68
+ end
69
+
70
+ @additions[key] += patch.additions
71
+ @deletions[key] += patch.deletions
72
+
73
+ churn = patch.additions + patch.deletions.abs
74
+ @churn[key] += churn
75
+
76
+ total_churn = @churn[key]
77
+
78
+ if total_churn > @maximum
79
+ @maximum = total_churn
63
80
  end
64
81
 
65
82
  if @earliest_commit_at.nil? or time < @earliest_commit_at
@@ -114,9 +131,10 @@ module Git
114
131
 
115
132
  if parent = commit.parents.first
116
133
  # Documentation seems to imply this shouldn't be needed.
117
- diff = commit.diff(commit.parents.first.tree)
134
+ diff = parent.diff(commit.tree)
118
135
  else
119
- diff = commit.diff
136
+ empty_tree = Rugged::Tree.empty(commit.tree.repo)
137
+ diff = empty_tree.diff(commit.tree)
120
138
  end
121
139
 
122
140
  author = commit.author
@@ -140,7 +158,7 @@ module Git
140
158
  parts.pop # Remove file name
141
159
  root = parts[0...@depth]
142
160
 
143
- @directories[root] << commit
161
+ @directories[root].add(commit, patch)
144
162
  end
145
163
  end
146
164
 
@@ -40,12 +40,13 @@ module Git
40
40
  attr :commits
41
41
  attr :title
42
42
 
43
- def ramp(x, max = commits.maximum)
44
- i = x.to_f / max
45
- # j = Math::sqrt(i)
46
- # k = i ** 2
47
- # return interpolate(i, [j], [k])[0]
48
- return i
43
+ def ramp(i, max = commits.maximum)
44
+ x = i.to_f / max
45
+
46
+ # Smoothstep:
47
+ # return (3*x*x - 2*x*x*x)
48
+
49
+ return Math::sqrt(x)
49
50
  end
50
51
 
51
52
  def interpolate(t, x, y)
@@ -62,6 +62,10 @@ table.summary {
62
62
  flex-shrink: 0;
63
63
  }
64
64
 
65
+ .heatmap ul.data li:hover {
66
+ background-color: rgba(0, 0, 0, 0.1);
67
+ }
68
+
65
69
  .heatmap .hover .box, .heatmap ul.paths li.hover {
66
70
  background-color: rgba(0, 0, 0, 0.2);
67
71
  }
@@ -27,9 +27,9 @@
27
27
  <li class="stats">
28
28
  <?r commits.each_period do |period| ?>
29
29
  <?r if period_commits = aggregate.periods[period]
30
- size = period_commits.size
30
+ size = aggregate.churn[period]
31
31
  ?>
32
- <a class="temperature box" style="background-color: #{background_color(size)}" title="#{period_commits.collect(&:oid).join(', ')}">#{size}</a>
32
+ <a class="temperature box" style="background-color: #{background_color(size)}" title="+#{aggregate.additions[period]}/-#{aggregate.deletions[period]} #{period_commits.collect(&:oid).join(', ')}">#{size}</a>
33
33
  <?r else ?>
34
34
  <div class="box"></div>
35
35
  <?r end ?>
@@ -1,5 +1,25 @@
1
+ # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
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
11
+ # all 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 NONINFRINGEMENT. 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
19
+ # THE SOFTWARE.
20
+
1
21
  module Git
2
- module Heatmap
3
- VERSION = "0.2.0"
4
- end
22
+ module Heatmap
23
+ VERSION = "0.2.1"
24
+ end
5
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-heatmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -122,6 +122,7 @@ files:
122
122
  - Gemfile
123
123
  - README.md
124
124
  - Rakefile
125
+ - Screenshot.png
125
126
  - bin/git-heatmap
126
127
  - git-heatmap.gemspec
127
128
  - lib/git/heatmap.rb
@@ -152,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  requirements: []
155
- rubygems_version: 3.0.4
156
+ rubygems_version: 3.0.3
156
157
  signing_key:
157
158
  specification_version: 4
158
159
  summary: Generate heatmap style visualisations based on git history.