Sha256: 99740190a46b70e8bf158c81f5f6f8145e6ae4a6dfd2b305241889acf1b01ff1

Contents?: true

Size: 1.03 KB

Versions: 170

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'active_support/core_ext/module/delegation'
require 'eac_ruby_utils/simple_cache'
require 'avm/git/commit/diff_tree_line'

module Avm
  module Git
    class Commit
      class File
        include ::EacRubyUtils::SimpleCache

        attr_reader :git, :diff_tree

        # git: [EacGit::Local]
        # diff_tree_tree: a line of command "git diff-tree --no-commit-id -r --full-index"'s output
        def initialize(git, diff_tree_line)
          @git = git
          @diff_tree = ::Avm::Git::Commit::DiffTreeLine.new(diff_tree_line)
        end

        delegate(*::Avm::Git::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(sha1)
          return 0 if /\A0+\z/.match(sha1)

          git.command('cat-file', '-s', sha1).execute!.strip.to_i
        end
      end
    end
  end
end

Version data entries

170 entries across 170 versions & 4 rubygems

Version Path
avm-git-0.18.0 lib/avm/git/commit/file.rb
eac_tools-0.94.0 sub/avm-git/lib/avm/git/commit/file.rb
avm-git-0.17.0 lib/avm/git/commit/file.rb
eac_tools-0.86.5 sub/avm-git/lib/avm/git/commit/file.rb
avm-git-0.16.0 lib/avm/git/commit/file.rb
eac_tools-0.86.4 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.86.3 sub/avm-git/lib/avm/git/commit/file.rb
avm-git-0.15.0 lib/avm/git/commit/file.rb
eac_tools-0.86.2 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.84.0 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.83.0 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.82.0 sub/avm-git/lib/avm/git/commit/file.rb
avm-git-0.14.0 lib/avm/git/commit/file.rb
eac_tools-0.81.0 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.80.0 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.79.0 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.78.0 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.77.1 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.77.0 sub/avm-git/lib/avm/git/commit/file.rb
eac_tools-0.76.1 sub/avm-git/lib/avm/git/commit/file.rb