Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added support for setting bugfix indicator words #5

Merged
merged 1 commit into from

2 participants

Robert Pitts Ilya Grigorik
Robert Pitts

This should allow the tool to work across different peoples commit styles.

Eventually should probably allow them to set prefs in a config file, and probably refactor the main lib in support of that... but until then ;)

-w, --words ["w1,w2"] bugfix indicator, ie: "fixes,closed"

Cheers.

Ilya Grigorik igrigorik merged commit 559e9c7 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 15, 2011
  1. Robert Pitts

    Support setting Bugfix indicator

    rbxbx authored
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 4 deletions.
  1. +6 −1 bin/bugspots
  2. +9 −3 lib/bugspots/scanner.rb
7 bin/bugspots
View
@@ -17,6 +17,11 @@ OptionParser.new do |opts|
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|
options[:display_timestamps] = true
@@ -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
12 lib/bugspots/scanner.rb
View
@@ -5,12 +5,18 @@ 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 = []
+ 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 =~ /fix(es|ed)|close(s|d)/
+ if commit.message =~ message_matchers
files = commit.stats.files.map {|s| s.first}
fixes << Fix.new(commit.short_message, commit.date, files)
end
@@ -30,4 +36,4 @@ def self.scan(repo, depth = 500)
return fixes, spots
end
-end
+end
Something went wrong with that request. Please try again.