class Gitomator::ServiceProvider::GitShell

Public Instance Methods

_run_command(cmd, opts = {}) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 54
def _run_command(cmd, opts = {})
  system({}, cmd, opts)
end
_run_git_command(cmd, local_repo_root, opts = {}) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 58
def _run_git_command(cmd, local_repo_root, opts = {})
  opts[:chdir] = local_repo_root
  unless cmd.strip.start_with? 'git'
    cmd = 'git ' + cmd
  end
  _run_command(cmd, opts)
end
add(local_repo_root, path, opts={}) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 14
def add(local_repo_root, path, opts={})
  _run_git_command("add #{path}", local_repo_root, opts)
end
checkout(local_repo_root, branch, opts) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 23
def checkout(local_repo_root, branch, opts)
  cmd = 'checkout '
  if opts[:is_new]
    cmd += '-b '
  end
  cmd += branch
  if opts[:is_remote]
    cmd += " origin/#{branch}"
  end

  _run_git_command(cmd, local_repo_root, {})
end
clone(repo_url, local_repo_root, opts) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 5
def clone(repo_url, local_repo_root, opts)
  _run_command("git clone #{repo_url} #{local_repo_root}", opts = {})
end
command(local_repo_root, command) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 47
def command(local_repo_root, command)
  _run_git_command(command, local_repo_root, opts = {})
end
commit(local_repo_root, message, opts={}) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 18
def commit(local_repo_root, message, opts={})
  cmd = "commit -m \"#{message.gsub('"', '\\\"')}\""
  _run_git_command(cmd, local_repo_root, opts)
end
init(local_repo_root, opts = {}) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 9
def init(local_repo_root, opts = {})
  Dir.mkdir(local_repo_root) unless Dir.exists?(local_repo_root)
  _run_git_command("init", local_repo_root)
end
push(local_repo_root, remote, opts) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 42
def push(local_repo_root, remote, opts)
  raise "Unsupported"
end
set_remote(local_repo_root, remote, url, opts) click to toggle source
# File lib/gitomator/service_provider/git_shell.rb, line 36
def set_remote(local_repo_root, remote, url, opts)
  cmd = "remote #{opts[:create] ? 'add' : 'set-url'} #{remote} #{url}"
  opts.delete :create
  _run_git_command(cmd, local_repo_root, opts)
end