Sha256: 5007e3ee02a28067485de84626a751beaf03f4f8a5cfdea1568b4a3a9d20d7ad

Contents?: true

Size: 981 Bytes

Versions: 8

Compression:

Stored size: 981 Bytes

Contents

module TerraspaceBundler::Util
  module Git
    include TB::Util::Logging

    def sh(command)
      command = "#{command} 2>&1" # always need output for the sha
      logger.debug "=> #{command}"
      out = `#{command}`
      unless $?.success?
        if command.include?("git")
          raise TB::GitError.new("#{command}\n#{out}")
        else
          logger.error "ERROR: running #{command}".color(:red)
          logger.error out
          exit $?.exitstatus
        end
      end
      out
    end

    def git(command)
      sh("git #{command}")
    rescue TB::GitError => e
      action, version = command.split(' ')
      if action == "checkout" && version !~ /^v/
        command = "checkout v#{version}"
        retry
      else
        logger.error "ERROR: There was a git error".color(:red)
        logger.error "Current dir: #{Dir.pwd}"
        logger.error "The error occur when running:"
        logger.error e.message
      end
      exit 1
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
terraspace-bundler-0.5.0 lib/terraspace_bundler/util/git.rb
terraspace-bundler-0.4.4 lib/terraspace_bundler/util/git.rb
terraspace-bundler-0.4.3 lib/terraspace_bundler/util/git.rb
terraspace-bundler-0.4.2 lib/terraspace_bundler/util/git.rb
terraspace-bundler-0.4.1 lib/terraspace_bundler/util/git.rb
terraspace-bundler-0.4.0 lib/terraspace_bundler/util/git.rb
terraspace-bundler-0.3.4 lib/terraspace_bundler/util/git.rb
terraspace-bundler-0.3.3 lib/terraspace_bundler/util/git.rb