diff --git a/lib/pronto.rb b/lib/pronto.rb index ff21c938..0312702c 100644 --- a/lib/pronto.rb +++ b/lib/pronto.rb @@ -1,4 +1,5 @@ require 'rugged' +require 'forwardable' require 'pronto/git/repository' require 'pronto/git/patches' diff --git a/lib/pronto/git/line.rb b/lib/pronto/git/line.rb index 0f495471..e306fc47 100644 --- a/lib/pronto/git/line.rb +++ b/lib/pronto/git/line.rb @@ -1,5 +1,3 @@ -require 'forwardable' - module Pronto module Git class Line < Struct.new(:line, :patch, :hunk) diff --git a/lib/pronto/git/patch.rb b/lib/pronto/git/patch.rb index 1b4eb9b9..268634d1 100644 --- a/lib/pronto/git/patch.rb +++ b/lib/pronto/git/patch.rb @@ -3,20 +3,16 @@ module Pronto module Git class Patch < Struct.new(:patch, :repo) - def delta - patch.delta - end + extend Forwardable - def hunks - patch.hunks - end + def_delegators :patch, :delta, :hunks, :stat def additions - patch.stat[0] + stat[0] end def deletions - patch.stat[1] + stat[1] end def blame(lineno) @@ -25,7 +21,7 @@ def blame(lineno) def lines @lines ||= begin - patch.map do |hunk| + hunks.map do |hunk| hunk.lines.map { |line| Line.new(line, self, hunk) } end.flatten.compact end @@ -41,7 +37,7 @@ def deleted_lines def new_file_full_path repo_path = Pathname.new(repo.path).parent - repo_path.join(patch.delta.new_file[:path]) + repo_path.join(delta.new_file[:path]) end end end