Sha256: cceb1aece35055ecb3bcd0252b09bceacf4956b6582e57b9849a852c3987e7e4

Contents?: true

Size: 771 Bytes

Versions: 21

Compression:

Stored size: 771 Bytes

Contents

module Churn

  #analizes git SCM to find recently changed files, and what lines have been altered
  class GitAnalyzer < SourceControl
    def get_logs
      `git log #{date_range} --name-only --pretty=format:`.split(/\n/).reject{|line| line == ""}
    end
    
    def get_revisions
      `git log #{date_range} --pretty=format:"%H"`.split(/\n/).reject{|line| line == ""}
    end
    
    private

    def get_diff(revision, previous_revision)
      `git diff #{revision} #{previous_revision} --unified=0`.split(/\n/).select{|line| line.match(/^@@/) || line.match(/^---/) || line.match(/^\+\+\+/) }
    end

    def date_range
      if @start_date
        date = Chronic.parse(@start_date)
        "--after=#{date.strftime('%Y-%m-%d')}"
      end
    end
    
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
churn-0.0.13 lib/churn/git_analyzer.rb