Class: EacGit::Local::Remote

Inherits:
Object
  • Object
show all
Includes:
RemoteLike
Defined in:
lib/eac_git/local/remote.rb,
lib/eac_git/local/remote/push.rb

Defined Under Namespace

Classes: Push

Constant Summary collapse

NO_SUCH_REMOTE_CODE =
512

Instance Method Summary collapse

Methods included from RemoteLike

#fetch, #ls

Instance Method Details

#add(url) ⇒ String

Returns:

  • (String)


14
15
16
# File 'lib/eac_git/local/remote.rb', line 14

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

#exist?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/eac_git/local/remote.rb', line 19

def exist?
  url.present?
end

#git_commandEacRubyUtils::Envs::Command

Returns EacRubyUtils::Envs::Command.

Returns:

  • (EacRubyUtils::Envs::Command)

    EacRubyUtils::Envs::Command



24
25
26
# File 'lib/eac_git/local/remote.rb', line 24

def git_command(*)
  local.command(*)
end

#pushEacGit::Local::Remote::Push



29
30
31
# File 'lib/eac_git/local/remote.rb', line 29

def push
  ::EacGit::Local::Remote::Push.new(self)
end

#remote_referenceString

Returns:

  • (String)


34
35
36
# File 'lib/eac_git/local/remote.rb', line 34

def remote_reference
  name
end

#removeString

Returns:

  • (String)


39
40
41
# File 'lib/eac_git/local/remote.rb', line 39

def remove
  local.command('remote', 'remove', name).execute!
end

#urlString?

Returns:

  • (String, nil)


44
45
46
# File 'lib/eac_git/local/remote.rb', line 44

def url
  url_get(exit_outputs: { NO_SUCH_REMOTE_CODE => nil }).if_present(nil, &:strip)
end

#url=(new_url) ⇒ String

Returns:

  • (String)


49
50
51
52
53
54
55
56
57
# File 'lib/eac_git/local/remote.rb', line 49

def url=(new_url)
  case [exist?, new_url.present?]
  when [false, false] # do nothing
  when [false, true] then add(new_url)
  when [true, false] then remove
  when [true, true] then url_set(new_url)
  else ibr
  end
end

#url_getString?

Returns:

  • (String, nil)


60
61
62
# File 'lib/eac_git/local/remote.rb', line 60

def url_get(**)
  local.command('remote', 'get-url', name).execute!(**)
end

#url_set(url) ⇒ String

Parameters:

  • url (String)

Returns:

  • (String)


66
67
68
# File 'lib/eac_git/local/remote.rb', line 66

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