Class: EacLauncher::Git::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_launcher/git/remote.rb

Instance Method Summary collapse

Instance Method Details

#add(url) ⇒ Object

git remote add …



22
23
24
# File 'lib/eac_launcher/git/remote.rb', line 22

def add(url)
  git.execute!('remote', 'add', name, url)
end

#exist?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/eac_launcher/git/remote.rb', line 10

def exist?
  git.execute!('remote').each_line.any? { |line| line.strip == name }
end

#lsObject



14
15
16
17
18
19
# File 'lib/eac_launcher/git/remote.rb', line 14

def ls
  git.execute!(['ls-remote', name]).each_line.map do |line|
    x = line.strip.split(/\s+/)
    [x[1], x[0]]
  end.to_h
end

#removeObject

git remote rm …



27
28
29
# File 'lib/eac_launcher/git/remote.rb', line 27

def remove
  git.execute!('remote', 'rm', name)
end

#urlObject

git remote get-url …



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

def url
  git.execute!('remote', 'get-url', name).strip.if_present(nil)
end

#url=(url) ⇒ Object

Add or set URL if url is present, remove remote if is blank.



42
43
44
45
46
47
48
49
50
# File 'lib/eac_launcher/git/remote.rb', line 42

def url=(url)
  if exist? && url.blank?
    remove
  elsif exist? && self.url != url
    url_set(url)
  elsif !exist?
    add(url)
  end
end

#url_set(url) ⇒ Object

git remote set-url …



37
38
39
# File 'lib/eac_launcher/git/remote.rb', line 37

def url_set(url)
  git.execute!('remote', 'set-url', name, url)
end