Sha256: 3ed41511c8240796ee07a552336b1b67c00216019a8ec4905f1f5735891bb946

Contents?: true

Size: 1000 Bytes

Versions: 12

Compression:

Stored size: 1000 Bytes

Contents

require 'pry'
require_relative 'options/diff'
require_relative '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

12 entries across 12 versions & 1 rubygems

Version Path
inch-0.4.4 lib/inch/cli/command/diff.rb
inch-0.4.4.rc4 lib/inch/cli/command/diff.rb
inch-0.4.4.rc3 lib/inch/cli/command/diff.rb
inch-0.4.4.rc2 lib/inch/cli/command/diff.rb
inch-0.4.4.rc1 lib/inch/cli/command/diff.rb
inch-0.4.3 lib/inch/cli/command/diff.rb
inch-0.4.3.rc2 lib/inch/cli/command/diff.rb
inch-0.4.3.rc1 lib/inch/cli/command/diff.rb
inch-0.4.2 lib/inch/cli/command/diff.rb
inch-0.4.1 lib/inch/cli/command/diff.rb
inch-0.4.0 lib/inch/cli/command/diff.rb
inch-0.4.0.rc3 lib/inch/cli/command/diff.rb