Sha256: bf15e7bf329fbe9f1f6cdf8d78259e32be8ef72627602250a8b059cbab49ea97

Contents?: true

Size: 967 Bytes

Versions: 3

Compression:

Stored size: 967 Bytes

Contents

module Lono::Bundler::Util
  module Git
    include 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 LB::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 LB::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

3 entries across 3 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc3 lib/lono/bundler/util/git.rb
lono-8.0.0.pre.rc2 lib/lono/bundler/util/git.rb
lono-8.0.0.pre.rc1 lib/lono/bundler/util/git.rb