Module: TerraspaceBundler::Util::Git
- Includes:
- TB::Util::Logging
- Defined in:
- lib/terraspace_bundler/util/git.rb
Instance Method Summary collapse
Instance Method Details
#git(command) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/terraspace_bundler/util/git.rb', line 21 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. end exit 1 end |
#sh(command) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/terraspace_bundler/util/git.rb', line 5 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 |