Sha256: 3da9b45dc80dfd689dd5aa1ca301e251ef0bedba593bfd1474b0456930124c03

Contents?: true

Size: 1.5 KB

Versions: 57

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require 'eac_git/executables'
require 'eac_ruby_utils/envs'
require 'git'
require 'avm/launcher/paths/real'

module Avm
  module Git
    module Launcher
      class Base < ::Avm::Launcher::Paths::Real
        module Underlying
          def command(*args)
            args, options = build_args(args)
            r = ::EacGit::Executables.git.command(*args)
            (options[:exit_outputs] || {}).each do |status_code, result|
              r = r.status_result(status_code, result)
            end
            r
          end

          %w[execute execute! system system!].each do |exec_type|
            define_method exec_type do |*args|
              begin
                command(*args).send(exec_type)
              rescue ::EacRubyUtils::Envs::ExecutionError
                raise ::Avm::Git::Launcher::Error
              end
            end
          end

          def init
            git
            self
          end

          private

          def build_args(args)
            options = {}
            if args.last.is_a?(Hash)
              options = args.last
              args.pop
            end
            args = args.first if args.first.is_a?(Array)
            [['-C', self, '--no-pager'] + args, options]
          end

          def git_uncached
            FileUtils.mkdir_p(self)
            if File.exist?(subpath('.git'))
              ::Git.open(self)
            else
              ::Git.init(self)
            end
          end
        end
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 2 rubygems

Version Path
eac_tools-0.75.1 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.75.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.74.1 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.74.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.73.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.72.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.70.1 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.70.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.69.1 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.69.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.68.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
avm-git-0.13.3 lib/avm/git/launcher/base/underlying.rb
eac_tools-0.67.1 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.67.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.66.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.65.1 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.65.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.64.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.63.0 sub/avm-git/lib/avm/git/launcher/base/underlying.rb
eac_tools-0.62.1 sub/avm-git/lib/avm/git/launcher/base/underlying.rb