Sha256: a8ec4ce720e9a2a2ebbeeebffa51971e106eae573482c26377a0621b4225e442

Contents?: true

Size: 1.04 KB

Versions: 181

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_git/local/commit/diff_tree_line'

module EacGit
  class Local
    class Commit
      class ChangedFile
        enable_simple_cache

        attr_reader :commit, :diff_tree

        # @param commit [EacGit::Local::Commit]
        # @param diff_tree_line [String] A line from command "repo diff-tree --no-commit-id -r
        #   --full-index"'s output.
        def initialize(commit, diff_tree_line)
          @commit = commit
          @diff_tree = ::EacGit::Local::Commit::DiffTreeLine.new(diff_tree_line)
        end

        delegate(*::EacGit::Local::Commit::DiffTreeLine::FIELDS, to: :diff_tree)

        def to_s
          "#{path}|#{status}"
        end

        def src_size_uncached
          size(src_sha1)
        end

        def dst_size_uncached
          size(dst_sha1)
        end

        private

        def size(id)
          return 0 if /\A0+\z/.match(id)

          commit.repo.command('cat-file', '-s', id).execute!.strip.to_i
        end
      end
    end
  end
end

Version data entries

181 entries across 181 versions & 3 rubygems

Version Path
eac_tools-0.86.5 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.86.4 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.86.3 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_git-0.16.0 lib/eac_git/local/commit/changed_file.rb
eac_tools-0.86.2 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_git-0.15.0 lib/eac_git/local/commit/changed_file.rb
eac_tools-0.84.2 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.84.1 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.84.0 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.83.0 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.82.0 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.81.0 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.80.0 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.79.0 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.78.0 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.77.1 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.77.0 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.76.1 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.76.0 sub/eac_git/lib/eac_git/local/commit/changed_file.rb
eac_tools-0.75.2 sub/eac_git/lib/eac_git/local/commit/changed_file.rb