Sha256: 2f567f7c59c5645a4005bcc0429b9718449a6c752375731b08068ebd752463d3

Contents?: true

Size: 892 Bytes

Versions: 1

Compression:

Stored size: 892 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

    def get_commit_history
      `git log --reverse --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

1 entries across 1 versions & 1 rubygems

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