Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Added support for setting bugfix indicator words #5

Merged
merged 1 commit into from over 2 years ago

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
Ilya Grigorik igrigorik closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 15, 2011
Robert Pitts Support setting Bugfix indicator 559e9c7
This page is out of date. Refresh to see the latest.
7  bin/bugspots
@@ -17,6 +17,11 @@ OptionParser.new do |opts|
17 17
     options[:depth] = d.to_i
18 18
   end
19 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
+
20 25
   # Option: Set Timestamp Display
21 26
   opts.on('--display-timestamps', 'show timestamps of each identified fix commit') do |dt|
22 27
     options[:display_timestamps] = true
@@ -28,7 +33,7 @@ options[:depth] ||= 500
28 33
 
29 34
 puts "Scanning #{ARGV[0]} repo".foreground(:green)
30 35
 
31  
-fixes, spots = Bugspots.scan(ARGV[0], options[:depth])
  36
+fixes, spots = Bugspots.scan(ARGV[0], options[:depth], options[:words])
32 37
 
33 38
 puts "\tFound #{fixes.size} bugfix commits, with #{spots.size} hotspots:".foreground(:yellow)
34 39
 puts
12  lib/bugspots/scanner.rb
@@ -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 =~ /fix(es|ed)|close(s|d)/
  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
@@ -30,4 +36,4 @@ def self.scan(repo, depth = 500)
30 36
 
31 37
     return fixes, spots
32 38
   end
33  
-end
  39
+end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.