Sha256: 406ce45e11d16b6a40b8310853e48d27e1d91d283742e498261f0ef4d463cf27
Contents?: true
Size: 1.43 KB
Versions: 5
Compression:
Stored size: 1.43 KB
Contents
module Churn # Analyzes git SCM to find recently changed files, and what lines have been altered class GitAnalyzer < SourceControl # @return [Boolean] def self.supported? !!(`git branch 2>&1` && $?.success?) end # @return [Array] def get_logs `git log #{date_range} --name-only --pretty=format:`.split(/\n/).reject{|line| line == ""} end # @return [Array] def get_revisions `git log #{date_range} --pretty=format:"%H"`.split(/\n/).reject{|line| line == ""} end def generate_history(starting_point) get_commit_history.each do |commit| `git checkout #{commit}` commit_date = `git show -s --format="%ci"` commit_date = Time.parse(commit_date) next if commit_date < starting_point #7776000 == 3.months without adding active support depenancy start_date = (commit_date - 7776000) `churn -s "#{start_date}"` end ensure `git checkout master` end private def get_commit_history `git log --reverse --pretty=format:"%H"`.split(/\n/).reject{|line| line == ""} end def get_diff(revision, previous_revision) `git diff #{revision} #{previous_revision} --no-ext-diff --unified=0`.split(/\n/).select{|line| /^@@|^---|^\+\+\+/ =~ line } 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
5 entries across 5 versions & 1 rubygems