Navigation Menu

Skip to content

Commit

Permalink
Added a "-b" and "--branch" option to the executable. Defaults to "ma…
Browse files Browse the repository at this point in the history
…ster".
  • Loading branch information
Michael Pellon committed Dec 15, 2011
1 parent cb2de47 commit c89647b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions bin/bugspots
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/bugspots/scanner.rb
Expand Up @@ -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 = []

Expand All @@ -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)
Expand Down

0 comments on commit c89647b

Please sign in to comment.