bugspots 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/bugspots +23 -3
- data/lib/bugspots/scanner.rb +10 -4
- data/lib/bugspots/version.rb +1 -1
- metadata +5 -5
data/bin/bugspots
CHANGED
@@ -11,18 +11,39 @@ ARGV << '--help' if ARGV.empty?
|
|
11
11
|
options = {}
|
12
12
|
OptionParser.new do |opts|
|
13
13
|
opts.banner = "Usage: bugspots /path/to/git/repo"
|
14
|
+
|
15
|
+
# Option: Set Depth
|
16
|
+
opts.on('-d', '--depth [depth]', 'depth of log crawl (integer)') do |d|
|
17
|
+
options[:depth] = d.to_i
|
18
|
+
end
|
19
|
+
|
20
|
+
# Option: Set Bugfix Indicator
|
21
|
+
opts.on('-w', '--words ["w1,w2"]', 'bugfix indicator, ie: "fixes,closed"') do |words|
|
22
|
+
options[:words] = words
|
23
|
+
end
|
24
|
+
|
25
|
+
# Option: Set Timestamp Display
|
26
|
+
opts.on('--display-timestamps', 'show timestamps of each identified fix commit') do |dt|
|
27
|
+
options[:display_timestamps] = true
|
28
|
+
end
|
14
29
|
end.parse!
|
15
30
|
|
31
|
+
# Set a reasonable default of depth
|
32
|
+
options[:depth] ||= 500
|
33
|
+
|
16
34
|
puts "Scanning #{ARGV[0]} repo".foreground(:green)
|
17
35
|
|
18
|
-
fixes, spots = Bugspots.scan(ARGV[0])
|
36
|
+
fixes, spots = Bugspots.scan(ARGV[0], options[:depth], options[:words])
|
19
37
|
|
20
38
|
puts "\tFound #{fixes.size} bugfix commits, with #{spots.size} hotspots:".foreground(:yellow)
|
21
39
|
puts
|
22
40
|
|
23
41
|
puts "\tFixes:".foreground(:green).underline
|
24
42
|
fixes.each do |fix|
|
25
|
-
|
43
|
+
message = "\t\t- "
|
44
|
+
message << "#{fix.date} " if options[:display_timestamps]
|
45
|
+
message << "#{fix.message}"
|
46
|
+
puts message.foreground(:yellow)
|
26
47
|
end
|
27
48
|
|
28
49
|
puts "\n"
|
@@ -30,4 +51,3 @@ puts "\tHotspots:".foreground(:green).underline
|
|
30
51
|
spots.each do |spot|
|
31
52
|
puts "\t\t#{spot.score}".foreground(:red) + " - #{spot.file}".foreground(:yellow)
|
32
53
|
end
|
33
|
-
|
data/lib/bugspots/scanner.rb
CHANGED
@@ -5,12 +5,18 @@ module Bugspots
|
|
5
5
|
Fix = Struct.new(:message, :date, :files)
|
6
6
|
Spot = Struct.new(:file, :score)
|
7
7
|
|
8
|
-
def self.scan(repo, depth = 500)
|
8
|
+
def self.scan(repo, depth = 500, words = nil)
|
9
9
|
repo = Grit::Repo.new(repo)
|
10
10
|
fixes = []
|
11
11
|
|
12
|
+
if words
|
13
|
+
message_matchers = /#{words.split(',').join('|')}/
|
14
|
+
else
|
15
|
+
message_matchers = /fix(es|ed)|close(s|d)/
|
16
|
+
end
|
17
|
+
|
12
18
|
repo.commits('master', depth).each do |commit|
|
13
|
-
if commit.message =~
|
19
|
+
if commit.message =~ message_matchers
|
14
20
|
files = commit.stats.files.map {|s| s.first}
|
15
21
|
fixes << Fix.new(commit.short_message, commit.date, files)
|
16
22
|
end
|
@@ -25,9 +31,9 @@ module Bugspots
|
|
25
31
|
end
|
26
32
|
|
27
33
|
spots = hotspots.sort_by {|k,v| v}.reverse.collect do |spot|
|
28
|
-
Spot.new(spot.first, spot.last
|
34
|
+
Spot.new(spot.first, sprintf('%.4f', spot.last))
|
29
35
|
end
|
30
36
|
|
31
37
|
return fixes, spots
|
32
38
|
end
|
33
|
-
end
|
39
|
+
end
|
data/lib/bugspots/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugspots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-15 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: grit
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153295780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153295780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rainbow
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153295360 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153295360
|
36
36
|
description: Implementation of simple bug prediction hotspot heuristic
|
37
37
|
email:
|
38
38
|
- ilya@igvita.com
|