Permalink
Browse files

Churn now supports git (thanks to Erik St Martin) and release of 0.8.0

  • Loading branch information...
1 parent 93c83fd commit 2825a575b752e12165c9abe146e2e48e570f436c @jscruggs jscruggs committed Oct 7, 2008
Showing with 33 additions and 12 deletions.
  1. +8 −0 History.txt
  2. +0 −2 TODO.txt
  3. +24 −9 lib/tasks/churn.rake
  4. +1 −1 metric_fu.gemspec
View
8 History.txt
@@ -1,3 +1,11 @@
+=== MetricFu 0.8.0 / 2008-10-06
+
+* Source Control Churn now supports git (thanks to Erik St Martin)
+* Flog Results are sorted by Highest Flog Score
+* Fix for a bunch of 'already initialized constant' warnings that metric_fu caused
+* Fixing bug so the flog reporter can handle methods with digits in the name (thanks to Andy Gregorowicz)
+* Internal Rake task now allows metric_fu to flog/churn itself
+
=== MetricFu 0.7.6 / 2008-09-15
* CHURN_OPTIONS has become MetricFu::CHURN_OPTIONS
View
2 TODO.txt
@@ -1,8 +1,6 @@
== TODO list
-* Sort Flog scores from worst to best
* Color code flog results with scale from: http://jakescruggs.blogspot.com/2008/08/whats-good-flog-score.html
-* Get churn to work with git
* Extract functionality from rake files and put under test
* Change churn start_date to not rely on Rails 1.day.ago functionality (so metric_fu can be used in non-Rails apps)
* Make integration with RSpec better (use SpecTask?)
View
33 lib/tasks/churn.rake
@@ -3,13 +3,23 @@ namespace :metrics do
desc "Which files change the most"
task :churn do
- date_range, minimum_churn_count = churn_options()
- svn_logs = `svn log #{date_range} --verbose`.split(/\n/).select {|line| line.strip =~ /^[A,M]/}
-
+ date_range, minimum_churn_count, scm = churn_options()
+
changes = {}
- svn_logs.each do |line|
- line.strip =~ /^[A,M] (.*)/
- changes[$1] ? changes[$1] += 1 : changes[$1] = 1
+ if scm == :git
+ git_logs = `git log #{date_range} --name-only --pretty=format:`.split(/\n/)
+ git_logs.reject!{|line| line == ""}
+
+ git_logs.each do |line|
+ changes[line] ? changes[line] += 1 : changes[line] = 1
+ end
+ else
+ svn_logs = `svn log #{date_range} --verbose`.split(/\n/).select {|line| line.strip =~ /^[A,M]/}
+
+ svn_logs.each do |line|
+ line.strip =~ /^[A,M] (.*)/
+ changes[$1] ? changes[$1] += 1 : changes[$1] = 1
+ end
end
write_churn_file(changes.reject {|file, change_count| change_count < minimum_churn_count})
system("open #{CHURN_DIR}/index.html") if PLATFORM['darwin']
@@ -20,12 +30,17 @@ namespace :metrics do
options = defined?(MetricFu::CHURN_OPTIONS) ? MetricFu::CHURN_OPTIONS : {}
if options[:start_date]
require RAILS_ROOT + '/config/environment'
- date_range = "--revision {#{options[:start_date].call.strftime('%Y-%m-%d')}}:{#{Time.now.strftime('%Y-%m-%d')}}"
+ if options[:scm] == :git
+ date_range = "--after=#{options[:start_date].call.strftime('%Y-%m-%d')}"
+ else
+ date_range = "--revision {#{options[:start_date].call.strftime('%Y-%m-%d')}}:{#{Time.now.strftime('%Y-%m-%d')}}"
+ end
else
date_range = ""
end
minimum_churn_count = options[:minimum_churn_count] ? options[:minimum_churn_count] : 5
- return date_range, minimum_churn_count
+ scm = options[:scm] == :git ? :git : :svn
+ return date_range, minimum_churn_count, scm
end
def write_churn_file changes
@@ -93,4 +108,4 @@ namespace :metrics do
</body>
</html>
EOS
-end
+end
View
2 metric_fu.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "metric_fu"
- s.version = "0.7.6"
+ s.version = "0.8.0"
s.summary = "Generates project metrics using Flog, RCov, Saikuro and more"
s.email = "jake.scruggs@gmail.com"
s.homepage = "http://metric-fu.rubyforge.org/"

0 comments on commit 2825a57

Please sign in to comment.