Sha256: 4aae9d77cca91ca1f6675cc12ad7a6012cafcd569c4aa82c5f88522ffc362e0c

Contents?: true

Size: 775 Bytes

Versions: 19

Compression:

Stored size: 775 Bytes

Contents

require "berkshelf/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

19 entries across 19 versions & 1 rubygems

Version Path
berkshelf-7.0.8 lib/berkshelf/mixin/git.rb
berkshelf-7.0.7 lib/berkshelf/mixin/git.rb
berkshelf-6.3.4 lib/berkshelf/mixin/git.rb
berkshelf-7.0.6 lib/berkshelf/mixin/git.rb
berkshelf-7.0.5 lib/berkshelf/mixin/git.rb
berkshelf-6.3.3 lib/berkshelf/mixin/git.rb
berkshelf-7.0.4 lib/berkshelf/mixin/git.rb
berkshelf-7.0.3 lib/berkshelf/mixin/git.rb
berkshelf-7.0.2 lib/berkshelf/mixin/git.rb
berkshelf-7.0.1 lib/berkshelf/mixin/git.rb
berkshelf-7.0.0 lib/berkshelf/mixin/git.rb
berkshelf-6.3.2 lib/berkshelf/mixin/git.rb
berkshelf-6.3.1 lib/berkshelf/mixin/git.rb
berkshelf-6.3.0 lib/berkshelf/mixin/git.rb
berkshelf-6.2.2 lib/berkshelf/mixin/git.rb
berkshelf-6.2.1 lib/berkshelf/mixin/git.rb
berkshelf-6.2.0 lib/berkshelf/mixin/git.rb
berkshelf-6.1.1 lib/berkshelf/mixin/git.rb
berkshelf-6.1.0 lib/berkshelf/mixin/git.rb