Permalink
Browse files

Added a "-b" and "--branch" option to the executable. Defaults to "ma…

…ster".
  • Loading branch information...
1 parent cb2de47 commit c89647bac4b37ddbef0eac38f1219530458d4f96 Michael Pellon committed Dec 15, 2011
Showing with 12 additions and 4 deletions.
  1. +10 −2 bin/bugspots
  2. +2 −2 lib/bugspots/scanner.rb
View
@@ -12,6 +12,11 @@ options = {}
OptionParser.new do |opts|
opts.banner = "Usage: bugspots /path/to/git/repo"
+ # Option: Set Branch
+ opts.on('-b', '--branch [name]', 'branch to crawl') do |b|
+ options[:branch] = b.to_s
+ end
+
# Option: Set Depth
opts.on('-d', '--depth [depth]', 'depth of log crawl (integer)') do |d|
options[:depth] = d.to_i
@@ -28,12 +33,15 @@ OptionParser.new do |opts|
end
end.parse!
-# Set a reasonable default of depth
+# Set a reasonable default of depth
options[:depth] ||= 500
+# Set master as the default branch
+options[:branch] ||= "master"
+
puts "Scanning #{ARGV[0]} repo".foreground(:green)
-fixes, spots = Bugspots.scan(ARGV[0], options[:depth], options[:words])
+fixes, spots = Bugspots.scan(ARGV[0], options[:branch], options[:depth], options[:words])
puts "\tFound #{fixes.size} bugfix commits, with #{spots.size} hotspots:".foreground(:yellow)
puts
View
@@ -5,7 +5,7 @@ module Bugspots
Fix = Struct.new(:message, :date, :files)
Spot = Struct.new(:file, :score)
- def self.scan(repo, depth = 500, words = nil)
+ def self.scan(repo, branch = "master", depth = 500, words = nil)
repo = Grit::Repo.new(repo)
fixes = []
@@ -15,7 +15,7 @@ def self.scan(repo, depth = 500, words = nil)
message_matchers = /fix(es|ed)|close(s|d)/
end
- repo.commits('master', depth).each do |commit|
+ repo.commits(branch, 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)

0 comments on commit c89647b

Please sign in to comment.