module Bringit::Pulling

Methods for pulling

Public Instance Methods

pull() click to toggle source
# File lib/bringit/pulling.rb, line 8
def pull
  if svn?
    pull_svn
  else
    pull_git
  end
end

Protected Instance Methods

pull_git() click to toggle source
# File lib/bringit/pulling.rb, line 32
def pull_git
  _out, status = Popen.popen(%w(git fetch --all), path.to_s)
  status.zero?
end
pull_svn() click to toggle source
# File lib/bringit/pulling.rb, line 22
def pull_svn
  _out_fetch, status_fetch = Popen.popen(%w(git svn fetch), path.to_s)

  ref = svn_has_trunk? ? 'trunk' : 'git-svn'
  cmd = %W(git update-ref refs/heads/master refs/remotes/#{ref})
  _out_update, status_update = Popen.popen(cmd, path.to_s)

  [status_fetch, status_update].all?(&:zero?)
end
svn?() click to toggle source
# File lib/bringit/pulling.rb, line 18
def svn?
  path.join('svn').directory?
end
svn_has_trunk?() click to toggle source
# File lib/bringit/pulling.rb, line 37
def svn_has_trunk?
  out, _status =
    Popen.popen(%w(git config svn-remote.svn.fetch), path.to_s)
  out.start_with?('trunk:')
end