Module: Escualo::Remote

Defined in:
lib/escualo/remote.rb

Class Method Summary collapse

Class Method Details

.attach(session, dir, name, session_options) ⇒ Object



3
4
5
6
7
# File 'lib/escualo/remote.rb', line 3

def self.attach(session, dir, name, session_options)
  remote_name = "escualo-#{name}-#{session_options.hostname}"
  remote_url = remote_git_url(name, session_options)
  session.tell! "cd #{dir} && git remote add #{remote_name} #{remote_url}"
end

.clone(session, dir, repo, options) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/escualo/remote.rb', line 17

def self.clone(session, dir, repo, options)
  repo_url = "https://github.com/#{repo}"
  session.tell! "git clone #{repo_url} #{dir}"
  if options.tag
    session.tell! "cd #{dir} && git checkout #{options.tag}"
  end
end

.push(session, dir) ⇒ Object



32
33
34
# File 'lib/escualo/remote.rb', line 32

def self.push(session, dir)
  session.tell! "cd #{dir} && for r in $(git remote show | grep escualo-); do git push $r HEAD; done"
end

.remote_git_url(name, session_options) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/escualo/remote.rb', line 9

def self.remote_git_url(name, session_options)
  if session_options.local || session_options.dockerized
    "/var/repo/#{name}.git"
  else
    "ssh://#{session_options.username}@#{session_options.hostname}:#{session_options.ssh_options[:port]}/var/repo/#{name}.git"
  end
end

.remotes(session, dir) ⇒ Object



25
26
27
28
29
30
# File 'lib/escualo/remote.rb', line 25

def self.remotes(session, dir)
  session
      .ask("cd #{dir} && git remote show")
      .split
      .select { |it| it.start_with? 'escualo-' }
end