module Takeoff::Helpers

Public Instance Methods

branches_up_to_date?(a, b) click to toggle source
# File lib/takeoff/helpers.rb, line 38
def branches_up_to_date?(a, b)
  latest_commit(a) == latest_commit(b)
end
diff(from, to, files, name_only: false) click to toggle source
# File lib/takeoff/helpers.rb, line 24
def diff(from, to, files, name_only: false)
  files.select! { |file| File.exist?(file) }
  `git diff #{from}..#{to} -U0 #{"--name-only" if name_only} #{files.join(" ")}`
end
execute(command) click to toggle source
# File lib/takeoff/helpers.rb, line 10
def execute(command)
  puts "$ #{command}"
  value = `#{command}`
  puts value

  raise unless $?.success?
  
  value
end
file_has_changed_locally?(file) click to toggle source
# File lib/takeoff/helpers.rb, line 29
def file_has_changed_locally?(file)
  `git ls-files -o -m -d --exclude-standard | grep -E #{Shellwords.escape(file)}`
  $?.success?
end
files_have_changed?(from, to, files) click to toggle source
# File lib/takeoff/helpers.rb, line 34
def files_have_changed?(from, to, files)
  !diff(from, to, files, name_only: true).blank?
end
latest_commit(branch) click to toggle source
# File lib/takeoff/helpers.rb, line 20
def latest_commit(branch)
  `git rev-parse --verify #{branch}`.strip
end
log(message = nil) click to toggle source
# File lib/takeoff/helpers.rb, line 5
def log(message = nil)
  puts
  puts "🚀  #{message}" if message
end