Sha256: 439bc279e88335e00b86b1b999672d4195889ccb5613da47eead01265f984481

Contents?: true

Size: 763 Bytes

Versions: 8

Compression:

Stored size: 763 Bytes

Contents

require 'buff/shell_out'

module Berkshelf
  module Mixin
    module Git
      # 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 = Buff::ShellOut.shell_out(%|git #{command}|)

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

        response.stdout.strip
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
berkshelf-5.5.0 lib/berkshelf/mixin/git.rb
berkshelf-5.4.0 lib/berkshelf/mixin/git.rb
berkshelf-5.3.0 lib/berkshelf/mixin/git.rb
berkshelf-5.2.0 lib/berkshelf/mixin/git.rb
berkshelf-5.1.0 lib/berkshelf/mixin/git.rb
berkshelf-5.0.0 lib/berkshelf/mixin/git.rb
berkshelf-4.3.5 lib/berkshelf/mixin/git.rb
berkshelf-4.3.3 lib/berkshelf/mixin/git.rb