Sha256: 5ae36597d7f0fd9e3a9f6640547982ffa0ed7c3e264aa17b379217c2587a7b9f

Contents?: true

Size: 777 Bytes

Versions: 3

Compression:

Stored size: 777 Bytes

Contents

require_relative "../shell_out"

module Berkshelf
  module Mixin
    module Git
      include Berkshelf::ShellOut
      # Perform a git command.
      #
      # @param [String] command
      #   the command to run
      # @param [Boolean] error
      #   whether to raise error if the command fails
      #
      # @raise [String]
      #   the +$stdout+ from the command
      def git(command, error = true)
        unless Berkshelf.which("git") || Berkshelf.which("git.exe") || Berkshelf.which("git.bat")
          raise GitNotInstalled.new
        end

        response = shell_out(%{git #{command}})

        if response.error?
          raise GitCommandError.new(command, cache_path, response.stderr)
        end

        response.stdout.strip
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
berkshelf-7.1.0 lib/berkshelf/mixin/git.rb
berkshelf-7.0.10 lib/berkshelf/mixin/git.rb
berkshelf-7.0.9 lib/berkshelf/mixin/git.rb