Sha256: dbd007ccee3bf646b14b27df9e9cde0a20ba1d3d6c562df67dd9cfb550f27096

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

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, to_config(@options),
                                          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|
            next unless rev
            git(work_dir, "rev-parse #{rev}").strip
          end
        end

        def work_dir
          Dir.pwd
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inch-0.5.0.rc5 lib/inch/cli/command/diff.rb
inch-0.5.0.rc4 lib/inch/cli/command/diff.rb