Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git://github.com/rbxbx/bugspots

Conflicts:
	bin/bugspots
	lib/bugspots/scanner.rb
  • Loading branch information...
commit 1c675150d1bfe0fc24202dc89df63849b48e2433 2 parents 6e9a894 + 559e9c7
@igrigorik authored
Showing with 16 additions and 6 deletions.
  1. +6 −2 bin/bugspots
  2. +10 −4 lib/bugspots/scanner.rb
View
8 bin/bugspots
@@ -16,6 +16,11 @@ OptionParser.new do |opts|
opts.on('-d', '--depth [depth]', 'depth of log crawl (integer)') do |d|
options[:depth] = d.to_i
end
+
+ # Option: Set Bugfix Indicator
+ opts.on('-w', '--words ["w1,w2"]', 'bugfix indicator, ie: "fixes,closed"') do |words|
+ options[:words] = words
+ end
# Option: Set Timestamp Display
opts.on('--display-timestamps', 'show timestamps of each identified fix commit') do |dt|
@@ -28,7 +33,7 @@ options[:depth] ||= 500
puts "Scanning #{ARGV[0]} repo".foreground(:green)
-fixes, spots = Bugspots.scan(ARGV[0], options[:depth])
+fixes, spots = Bugspots.scan(ARGV[0], options[:depth], options[:words])
puts "\tFound #{fixes.size} bugfix commits, with #{spots.size} hotspots:".foreground(:yellow)
puts
@@ -46,4 +51,3 @@ puts "\tHotspots:".foreground(:green).underline
spots.each do |spot|
puts "\t\t#{spot.score}".foreground(:red) + " - #{spot.file}".foreground(:yellow)
end
-
View
14 lib/bugspots/scanner.rb
@@ -5,13 +5,19 @@ module Bugspots
Fix = Struct.new(:message, :date, :files)
Spot = Struct.new(:file, :score)
- def self.scan(repo, depth = 500)
+ def self.scan(repo, depth = 500, words = nil)
repo = Grit::Repo.new(repo)
fixes = []
- repo.commits('master', depth).each do |commit|
- if commit.message =~ /fix(es|ed)|close(s|d)/
- files = commit.stats.files.map {|s| s.first}
+ if words
+ message_matchers = /#{words.split(',').join('|')}/
+ else
+ message_matchers = /fix(es|ed)|close(s|d)/
+ end
+
+ repo.commits('master', depth).each do |commit|
+ if commit.message =~ message_matchers
+ files = commit.stats.files.map {|s| s.first}
fixes << Fix.new(commit.short_message, commit.date, files)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.