module Coaster::Git

Public Class Methods

create(path) click to toggle source
# File lib/coaster/git.rb, line 21
def create(path)
  run_cmd(path.split('/')[0..-2].join('/'), "git init #{path}")
  run_cmd(path, "git commit --allow-empty -m 'initial commit'")
  Repository.new(path)
end

Public Instance Methods

run_cmd(path, command) click to toggle source
# File lib/coaster/git.rb, line 7
def run_cmd(path, command)
  puts "#{path}: #{command}"
  stdout, stderr, status = Open3.capture3(command, chdir: path)
  if status.success?
    puts "  ↳ success: #{stdout.split("\n").join("\n             ")}"
    stdout
  else
    raise "Error executing command\nPATH: #{path}\nCMD: #{command}\nSTDERR:\n  ↳ #{stderr.split("\n").join("\n    ")}\nSTDOUT:\n  ↳ #{stdout.split("\n").join("\n    ")}"
  end
end