Sha256: bc81018c3a626626d46b077584d3370135e314f4bbd8f3781339b8b67d1d2b7e

Contents?: true

Size: 797 Bytes

Versions: 12

Compression:

Stored size: 797 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, **kwargs)
        unless Berkshelf.which("git") || Berkshelf.which("git.exe") || Berkshelf.which("git.bat")
          raise GitNotInstalled.new
        end

        response = shell_out(%{git #{command}}, **kwargs)

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

        response.stdout.strip
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
berkshelf-8.0.15 lib/berkshelf/mixin/git.rb
berkshelf-8.0.13 lib/berkshelf/mixin/git.rb
berkshelf-8.0.12 lib/berkshelf/mixin/git.rb
berkshelf-8.0.9 lib/berkshelf/mixin/git.rb
berkshelf-8.0.7 lib/berkshelf/mixin/git.rb
berkshelf-8.0.5 lib/berkshelf/mixin/git.rb
berkshelf-8.0.2 lib/berkshelf/mixin/git.rb
berkshelf-8.0.1 lib/berkshelf/mixin/git.rb
berkshelf-8.0.0 lib/berkshelf/mixin/git.rb
berkshelf-7.2.2 lib/berkshelf/mixin/git.rb
berkshelf-7.2.1 lib/berkshelf/mixin/git.rb
berkshelf-7.2.0 lib/berkshelf/mixin/git.rb