Sha256: 1ce8d66fb49cd1d4ec63c5ede72af53eb89b170dde3000a46428456522a1e0e4

Contents?: true

Size: 1.46 KB

Versions: 23

Compression:

Stored size: 1.46 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|
              command(*args).send(exec_type)
            rescue ::EacRubyUtils::Envs::ExecutionError
              raise ::Avm::Git::Launcher::Error
            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

23 entries across 23 versions & 2 rubygems

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