class AnalDiffist::Anal

Public Class Methods

new() click to toggle source
# File lib/anal_diffist.rb, line 14
def initialize
  @diffist = AnalDiffist::StandardDiffist.new
end

Public Instance Methods

analyze_ref(ref_name) click to toggle source
# File lib/anal_diffist.rb, line 54
def analyze_ref ref_name
  begin
    checkout_revision ref_name
    puts "  analyzing revision: #{ref_name}"
    @diffist.do_analytics ref_name
  rescue Exception
    puts "Error in analyze_ref: " + $!.to_s
  end

end
checkout_revision(ref_name) click to toggle source
# File lib/anal_diffist.rb, line 65
def checkout_revision ref_name
    puts "  checking out revision: #{ref_name}"
    `git checkout -q #{ref_name}`
end
get_current_branch() click to toggle source
# File lib/anal_diffist.rb, line 43
def get_current_branch
  current_branch_raw = `git branch --no-color`
  lines = current_branch_raw.split("\n")
  current_branch_line = lines.detect{|x| x[0] == '*'}
  current_branch = current_branch_line.split(' ')[1]
end
get_refs_to_diff(current_branch, start_ref, end_ref) click to toggle source
# File lib/anal_diffist.rb, line 50
def get_refs_to_diff current_branch, start_ref, end_ref
  [ start_ref ||  `git merge-base HEAD origin/master`, end_ref || current_branch]
end
run(start_ref, end_ref) click to toggle source
# File lib/anal_diffist.rb, line 18
def run(start_ref, end_ref)
  current_branch = get_current_branch
  stashed = try_to_stash

  ref = get_refs_to_diff current_branch, start_ref, end_ref
  puts "\nAnaldiffizing: #{ref.join(" -> ")}"
  analyze_ref(ref[0])
  analyze_ref(ref[1])

  begin
    if current_branch != ref[1]
      puts "  checking out original revision: #{current_branch}"
      checkout_revision current_branch
    end
  rescue Exception
  end

  if stashed
    puts "unstashing"
    `git stash apply`
  end

  @diffist.report_results
end
try_to_stash() click to toggle source
# File lib/anal_diffist.rb, line 70
def try_to_stash
  result =  `git stash`
  stashed = !(result =~ /No local changes to save/)
  puts "stashed local uncommitted changes" if stashed
  stashed
end