Sha256: 2c9aaa3d48971e0454baf377d448f0bffd6b4590f1f8e76d01c1e4f05b08c29e

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

module Braid
  module Commands
    class Diff < Command
      def run(path = nil, options = {})
        path ? diff_one(path, options) : diff_all(options)
      end

      private

      def diff_all(options = {})
        # We don't want "git diff" to invoke the pager once for each mirror.
        # TODO: Invoke the default pager once for the entire output.
        Operations::with_modified_environment({ 'GIT_PAGER' => ''}) do
          config.mirrors.each do |path|
            separator
            msg "Diffing #{path}\n"
            separator
            show_diff(path, options)
          end
        end
      end

      def diff_one(path, options = {})
        show_diff(path, options)
      end

      def separator
        puts "=======================================================\n"
      end

      def show_diff(path, options = {})
        mirror = config.get!(path)
        setup_remote(mirror)
        mirror.fetch_base_revision_if_missing

        # XXX: Warn if the user specifies file paths that are outside the
        # mirror?  Currently, they just won't match anything.
        git.diff_to_stdout(*mirror.diff_args(*options['git_diff_args']))

        clear_remote(mirror, options)
      end

      def config_mode
        Config::MODE_READ_ONLY
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
braid-1.1.6 lib/braid/commands/diff.rb
braid-1.1.5 lib/braid/commands/diff.rb
braid-1.1.4 lib/braid/commands/diff.rb
braid-1.1.3 lib/braid/commands/diff.rb
braid-1.1.2 lib/braid/commands/diff.rb
braid-1.1.1 lib/braid/commands/diff.rb
braid-1.1.0 lib/braid/commands/diff.rb