Class: AnalDiffist::Anal
Instance Method Summary collapse
- #analyze_ref(ref_name) ⇒ Object
- #checkout_revision(ref_name) ⇒ Object
- #get_current_branch ⇒ Object
- #get_refs_to_diff(current_branch, start_ref, end_ref) ⇒ Object
-
#initialize ⇒ Anal
constructor
A new instance of Anal.
- #run(start_ref, end_ref) ⇒ Object
- #try_to_stash ⇒ Object
Constructor Details
#initialize ⇒ Anal
Returns a new instance of Anal.
14 15 16 |
# File 'lib/anal_diffist.rb', line 14 def initialize @diffist = AnalDiffist::StandardDiffist.new end |
Instance Method Details
#analyze_ref(ref_name) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# 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) ⇒ Object
65 66 67 68 |
# 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 ⇒ Object
43 44 45 46 47 48 |
# 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) ⇒ Object
50 51 52 |
# 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) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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 ⇒ Object
70 71 72 73 74 75 |
# 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 |