Sha256: 1feab8d9266acbc0d0ae6ec84eab68e7071fbaf688182fb263784e125b8b9bde

Contents?: true

Size: 1016 Bytes

Versions: 5

Compression:

Stored size: 1016 Bytes

Contents

require 'pry'
require 'inch/cli/command/options/diff'
require 'inch/cli/command/output/diff'

module Inch
  module CLI
    module Command
      class Diff < Base
        include Utils::ShellHelper

        register_command_as :diff

        def description
          'Shows a diff'
        end

        def usage
          'Usage: inch diff [REV..[REV]] [options]'
        end

        def run(*args)
          @options.parse(args)
          @options.verify

          before_rev, after_rev = revisions[0], revisions[1]
          diff = API::Diff.new(work_dir, before_rev, after_rev)

          Output::Diff.new(@options, diff.comparer)
        end

        private

        # @return [Array<String>] the revisions passed in the command_line
        def revisions
          @revisions ||= @options.revisions.map do |rev|
            if rev
              git(work_dir, "rev-parse #{rev}").strip
            end
          end
        end

        def work_dir
          Dir.pwd
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
inch-0.5.0.rc3 lib/inch/cli/command/diff.rb
inch-0.5.0.rc2 lib/inch/cli/command/diff.rb
inch-0.5.0.rc1 lib/inch/cli/command/diff.rb
inch-0.4.6 lib/inch/cli/command/diff.rb
inch-0.4.5 lib/inch/cli/command/diff.rb