Sha256: 37ea61c5d1f3536085d5697aa9887d087212e0f22dcdf36f8ce99bbe47ea3d61

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Lono::Bundler::Util
  module Git
    include Logging
    include Lono::Utils::Sh

    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

    # Different from Lono::Utils::Sh
    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc6 lib/lono/bundler/util/git.rb
lono-8.0.0.pre.rc5 lib/lono/bundler/util/git.rb
lono-8.0.0.pre.rc4 lib/lono/bundler/util/git.rb